package com.fingard.dsp.bank;

import com.fingard.FGBiz;
import com.fingard.constant.Format;
import com.fingard.diagnostics.LogHelper;
import com.fingard.dsp.bank.directbank.DirectBase;
import com.fingard.dsp.bank.directbank.PaymentState;
import com.fingard.dsp.bank.directbank.VerifyState;
import com.fingard.dsp.bank.directbank.bankInterface.*;
import com.fingard.dsp.bank.directbank.specialDeal.TransHelper;
import com.fingard.dsp.bank.reqrespobj.PacketType;
import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RequestBase;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.auditAccount.ReqAuditAccount;
import com.fingard.dsp.bank.reqrespobj.auth.ReqAuth;
import com.fingard.dsp.bank.reqrespobj.auth.ReqQryAuth;
import com.fingard.dsp.bank.reqrespobj.auth.RetAtsAuth;
import com.fingard.dsp.bank.reqrespobj.auth.detail.RetAtsAuthDetail;
import com.fingard.dsp.bank.reqrespobj.authcancelforrec.ReqAuthCancelForRec;
import com.fingard.dsp.bank.reqrespobj.authcancelforrec.ReqQryAuthCancelForRec;
import com.fingard.dsp.bank.reqrespobj.authcancelforrec.ReqQryRecAuthCancelInfo;
import com.fingard.dsp.bank.reqrespobj.authforrec.ReqAuthForRec;
import com.fingard.dsp.bank.reqrespobj.authforrec.ReqQryAuthForRec;
import com.fingard.dsp.bank.reqrespobj.authforrec.ReqQryRecAuthInfo;
import com.fingard.dsp.bank.reqrespobj.balance.Req7505HisBalQry;
import com.fingard.dsp.bank.reqrespobj.balance.Req7506BalQry;
import com.fingard.dsp.bank.reqrespobj.balancecheck.ReqBalCheckQry;
import com.fingard.dsp.bank.reqrespobj.balancecheckconfirm.ReqBalCheckConfirmQry;
import com.fingard.dsp.bank.reqrespobj.batchbill.*;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsQryBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batrecrefund.ReqBatRecRefund;
import com.fingard.dsp.bank.reqrespobj.batrecrefund.ReqQryBatRecRefund;
import com.fingard.dsp.bank.reqrespobj.batrecrefund.RetAtsQryBatRecRefund;
import com.fingard.dsp.bank.reqrespobj.billpool.*;
import com.fingard.dsp.bank.reqrespobj.cashpool.ReqCPAQCashPoolAccQry;
import com.fingard.dsp.bank.reqrespobj.cashpool.ReqCPASQCashPoolAccSignInfoQry;
import com.fingard.dsp.bank.reqrespobj.cashpool.ReqCPTQCashPoolTreeQry;
import com.fingard.dsp.bank.reqrespobj.certificatemailmsg.ReqCertificateMailedMsgQry;
import com.fingard.dsp.bank.reqrespobj.closeorder.ReqCloseOrder;
import com.fingard.dsp.bank.reqrespobj.closeorder.RetAtsCloseOrder;
import com.fingard.dsp.bank.reqrespobj.contract.*;
import com.fingard.dsp.bank.reqrespobj.contract.detail.RetAtsContractDetail;
import com.fingard.dsp.bank.reqrespobj.currencyexchange.ReqExchange;
import com.fingard.dsp.bank.reqrespobj.currencyexchange.ReqQryExchange;
import com.fingard.dsp.bank.reqrespobj.currencyexchange.RetAtsExchange;
import com.fingard.dsp.bank.reqrespobj.currencyexchange.detail.RetAtsExchangeDetail;
import com.fingard.dsp.bank.reqrespobj.currtransperiod.Req4005;
import com.fingard.dsp.bank.reqrespobj.currtransperiod.Req4006;
import com.fingard.dsp.bank.reqrespobj.currtransperiod.RetAtsCurrTransPer;
import com.fingard.dsp.bank.reqrespobj.currtransperiod.detail.RetAtsCurrTransPerDetail;
import com.fingard.dsp.bank.reqrespobj.decontract.ReqDeContract;
import com.fingard.dsp.bank.reqrespobj.decontract.RetAtsDeContract;
import com.fingard.dsp.bank.reqrespobj.decontract.detail.RetAtsDeContractDetail;
import com.fingard.dsp.bank.reqrespobj.deposit.Req7507DepQry;
import com.fingard.dsp.bank.reqrespobj.downloadcodefile.ReqQryCodeFile;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.*;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB001OperBillQryDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB009DrawBillQryProtocolDetail;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB009DrawBillQryTransDetail;
import com.fingard.dsp.bank.reqrespobj.elecbilltrans.*;
import com.fingard.dsp.bank.reqrespobj.entrust.*;
import com.fingard.dsp.bank.reqrespobj.exchangerate.ReqExchangeRateQry;
import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.ReqForeignCurrSingle;
import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.ReqQryForeignCurrSingle;
import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.RetAtsForeignCurrSingle;
import com.fingard.dsp.bank.reqrespobj.foreigncurrsingle.detail.RetAtsForeignCurrPayDetail;
import com.fingard.dsp.bank.reqrespobj.foreignexchange.ReqFX01;
import com.fingard.dsp.bank.reqrespobj.foreignexchange.ReqFX02;
import com.fingard.dsp.bank.reqrespobj.foreignexchange.RetAtsForeignCurrency;
import com.fingard.dsp.bank.reqrespobj.foreignexchange.detail.RetAtsForeignCurrencyDetail;
import com.fingard.dsp.bank.reqrespobj.frgcurrsingle.ReqCJFrgCurrSingleBat;
import com.fingard.dsp.bank.reqrespobj.frgcurrsingle.ReqQryCJFrgCurrSingleBat;
import com.fingard.dsp.bank.reqrespobj.frgcurrsinglecheck.ReqCJFrgCurrCheck;
import com.fingard.dsp.bank.reqrespobj.frgcurrsinglegetval.ReqCJFrgCurrGetVal;
import com.fingard.dsp.bank.reqrespobj.gateway.ReqGateway;
import com.fingard.dsp.bank.reqrespobj.getappid.ReqQueryGetAppId;
import com.fingard.dsp.bank.reqrespobj.getappid.RetAtsQueryGetAppId;
import com.fingard.dsp.bank.reqrespobj.importlc.ReqImportLCQry;
import com.fingard.dsp.bank.reqrespobj.invoicemsg.ReqInvoiceMsgQry;
import com.fingard.dsp.bank.reqrespobj.mailedmsg.ReqMailedMsgQry;
import com.fingard.dsp.bank.reqrespobj.ordermsg.ReqOrderMsgQry;
import com.fingard.dsp.bank.reqrespobj.otherelse.ReqOtherElse;
import com.fingard.dsp.bank.reqrespobj.otherelse.RetAtsOtherElse;
import com.fingard.dsp.bank.reqrespobj.privatemove.ReqPrivateMoveMsgQry;
import com.fingard.dsp.bank.reqrespobj.privatesale.ReqPrivateSaleMsgQry;
import com.fingard.dsp.bank.reqrespobj.pushinfotobank.ReqPushTransInfo;
import com.fingard.dsp.bank.reqrespobj.qrpay.ReqGenQRInfo;
import com.fingard.dsp.bank.reqrespobj.qrpay.RetAtsGenQRInfo;
import com.fingard.dsp.bank.reqrespobj.qryfinancerecinfo.ReqQryFinanceRecInfo;
import com.fingard.dsp.bank.reqrespobj.qryincustodyinfo.ReqQryInCustodyInfo;
import com.fingard.dsp.bank.reqrespobj.qryquotainfo.ReqQryQuotaInfo;
import com.fingard.dsp.bank.reqrespobj.qryrefund.ReqQryRefund;
import com.fingard.dsp.bank.reqrespobj.qryunduebillinfo.ReqQryUndueBillInfo;
import com.fingard.dsp.bank.reqrespobj.quotecheck.ReqAQ01BalQry;
import com.fingard.dsp.bank.reqrespobj.recrefund.ReqQryRecRefund;
import com.fingard.dsp.bank.reqrespobj.recrefund.ReqRecRefund;
import com.fingard.dsp.bank.reqrespobj.recrefund.RetAtsQryRecRefund;
import com.fingard.dsp.bank.reqrespobj.recrefund.RetAtsRecRefund;
import com.fingard.dsp.bank.reqrespobj.relationdn.ReqRelationDN;
import com.fingard.dsp.bank.reqrespobj.retailMsg.ReqRetailMsgQry;
import com.fingard.dsp.bank.reqrespobj.retailstockmsg.ReqRetailStockMsgQry;
import com.fingard.dsp.bank.reqrespobj.sendsmscode.ReqCheckSmsCode;
import com.fingard.dsp.bank.reqrespobj.sendsmscode.ReqSendSmsCode;
import com.fingard.dsp.bank.reqrespobj.single.*;
import com.fingard.dsp.bank.reqrespobj.single.detail.RetAtsSglDetail;
import com.fingard.dsp.bank.reqrespobj.smsrec.ReqSMSRec;
import com.fingard.dsp.bank.reqrespobj.statement.ReqQryStatement;
import com.fingard.dsp.bank.reqrespobj.statement.RetAtsStatement;
import com.fingard.dsp.bank.reqrespobj.subaccount.ReqQrySubAccount;
import com.fingard.dsp.bank.reqrespobj.subaccount.ReqUpdateSubAccount;
import com.fingard.dsp.bank.reqrespobj.transaction.Req7515TodayTrans;
import com.fingard.dsp.bank.reqrespobj.transaction.Req7516HisTrans;
import com.fingard.dsp.bank.reqrespobj.transaction.ReqTransactionReplenish;
import com.fingard.dsp.bank.reqrespobj.transaction.RetAtsTrans;
import com.fingard.dsp.bank.reqrespobj.transaction.detail.RetAtsTransDetail;
import com.fingard.dsp.bank.reqrespobj.unifiedorder.*;
import com.fingard.dsp.bank.reqrespobj.userinfo.ReqQryUserInfo;
import com.fingard.dsp.bank.reqrespobj.virtual.ReqQueryVirtualOrder;
import com.fingard.dsp.bank.reqrespobj.virtual.ReqVirtualOrder;
import com.fingard.dsp.bank.reqrespobj.virtual.RetAtsQueryVirtualOrder;
import com.fingard.dsp.bank.reqrespobj.virtual.RetAtsVirtualOrder;
import com.fingard.dsp.bank.reqrespobj.virtualaccount.Req7503BalQry;
import com.fingard.dsp.bank.sepro.ReceiptPro;
import com.fingard.dsp.bank.sepro.Simulate;
import com.fingard.dsp.bank.sepro.TransactionPro;
import com.fingard.dsp.bankset.BankFront;
import com.fingard.dsp.bankset.BankPayInfo;
import com.fingard.dsp.bankset.EnBfStatus;
import com.fingard.dsp.core.DSPSecurityData;
import com.fingard.dsp.entity.enums.ENDSPTransType;
import com.fingard.dsp.entity.enums.ENDirectInfoType;
import com.fingard.dsp.tcpserver.PayQryController;
import com.fingard.dsp.tcpserver.RequestNIO;
import com.fingard.generalobj.ExecResponse;
import com.fingard.io.FileHelper;
import com.fingard.luna.framework.boot.core.util.SpringContextHolder;
import com.fingard.text.StringHelper;
import com.fingard.text.XmlHelper;
import com.fingard.util.TransIDHelper;
import com.fingard.xml.XmlTextReader;
import com.fingard.xml.XmlTextWriter;

import java.io.BufferedReader;
import java.io.File;
import java.io.StringReader;
import java.util.*;

public class DealDirectBank {
    private static TransIDHelper _idHelper = new TransIDHelper(1, 9999);
    private static String detailReqSeqIDPath = "/ATSYH/TransReq/TransParam/DetailRecord";
    private BankFront preBankFront = null;

    /**
     * 原始ATS请求报文
     */
    private String oriAtsReqStr;

    public DealDirectBank() {
    }

    public DealDirectBank(String p_oriReqStr) {
        oriAtsReqStr = p_oriReqStr;
    }

    public static BankFront getBankFrontByHead(ReqRespHeader tmpHeader) throws NoSuchFieldException, IllegalAccessException {

        String tmpCorporation = tmpHeader.corporation;
        if (tmpCorporation == null || tmpCorporation.length() == 0) {
            tmpCorporation = "5000001";
        }

        String tmpGroup = tmpHeader.group;
        if (tmpGroup == null || tmpGroup.length() == 0) {
            tmpGroup = "Default";
        }

        String tmpKeyDirectBank = tmpHeader.bankCode;
        if (tmpHeader.bankCode != null && tmpHeader.bankCode.startsWith("FnGrd") && tmpHeader.bankCode.length() == 8) {
            tmpKeyDirectBank = "FnGrd01";
        }

//        BankFront cacheBankfront = getBankfrontFromCache(tmpHeader, tmpGroup);
//        if (cacheBankfront != null) {
//            return cacheBankfront;
//        }
        String tmpMapKey = tmpKeyDirectBank + "-" + tmpCorporation + "-" + tmpGroup + "-" + tmpHeader.tenant;
        if (FGBiz.dspCenter.bankFrontCenter.hashMapBankFront.containsKey(tmpMapKey)) {
            return FGBiz.dspCenter.bankFrontCenter.hashMapBankFront.get(tmpMapKey).getBankFrontByBalance(tmpHeader);
        }

        return null;

    }


    public void setBankFront(BankFront p_bf) {
        preBankFront = p_bf;
    }

    public BankFront getBankFront(ReqRespHeader tmpHeader) throws NoSuchFieldException, IllegalAccessException {
        if (preBankFront != null) {
            return preBankFront;
        }
        return getBankFrontByHead(tmpHeader);
    }

    public String getBankFront(PacketType tmpPckType, List<String> reqSeqID, String bgnDate) throws Exception {
        try {
            if (tmpPckType == PacketType.PayQuery) {
                if (reqSeqID.size() == 0) {
                    return "未能识别到支付唯一标识，请求有误！";
                } else if (StringHelper.isNullOrEmpty(bgnDate.replace(" ", ""))) {
                    return "未能识别到支付发起时间，请求有误！";
                } else {
                    BankPayInfo bankPayInfo = SpringContextHolder.getBean(BankPayInfo.class);
                    String result = bankPayInfo.getBankFront(bgnDate, reqSeqID.get(0));
                    if (result != null) {
                        return result;
                    }
                    boolean hasBankfront = FGBiz.dspCenter.bankFrontCenter.hashMapBankFront.containsKey(bankPayInfo.bankFrontKey);
                    if (hasBankfront) {
                        BankFront bankFrontByURID = FGBiz.dspCenter.bankFrontCenter.hashMapBankFront.get(bankPayInfo.bankFrontKey).getBankFrontByURID(bankPayInfo.bankFrontID);
                        setBankFront(bankFrontByURID);
                    } else {
                        //setBankFront(null);
                    }
                }

            } else {
                //setBankFront(null);
            }
        } catch (Exception ex) {
            throw new Exception(ex);
        }
        return null;
    }

    /**
     * 获取类反射全局路径名
     *
     * @param tmpHeader
     * @return String
     */
    public String getClassName(ReqRespHeader tmpHeader) {
        String reflectType = "";

        if (tmpHeader.transType.equals("7503") || tmpHeader.transType.equals("7504")) {
            reflectType = "VirtualAccount";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("7506") || tmpHeader.transType.equals("7505")) {
            reflectType = "Balance";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("7507".equals(tmpHeader.transType)) {//定期存单查询
            reflectType = "Deposit";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("7516") || tmpHeader.transType.equals("7515")) {
            reflectType = "Transaction";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("7508")) { //余额信息对账查询接口、余额对账结果确认提交
            reflectType = "BalanceCheck";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("7509")) {
            reflectType = "BalanceCheckConfirm";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("B001") || tmpHeader.transType.equals("B002") || tmpHeader.transType.equals("B004") || tmpHeader.transType.equals("B005") || tmpHeader.transType.equals("B006") || tmpHeader.transType.equals("B007") || tmpHeader.transType.equals("B008") || tmpHeader.transType.equals("B009") || tmpHeader.transType.equals("B010") || tmpHeader.transType.equals("B011")
                || tmpHeader.transType.equals("B012") || tmpHeader.transType.equals("B013")) { //电票
            reflectType = "ElecBill";
            tmpHeader.pckType = PacketType.EleQuery;
        } else if (tmpHeader.transType.equals("B003") || tmpHeader.transType.equals("B101") || tmpHeader.transType.equals("B102") || tmpHeader.transType.equals("B103") || tmpHeader.transType.equals("B104") || tmpHeader.transType.equals("B105") || tmpHeader.transType.equals("B106") || tmpHeader.transType.equals("B107") || tmpHeader.transType.equals("B108") || tmpHeader.transType.equals("B109") || tmpHeader.transType.equals("B110") || tmpHeader.transType.equals("B111") || tmpHeader.transType.equals("B112") || tmpHeader.transType.equals("B113") || tmpHeader.transType.equals("B119")
                || tmpHeader.transType.equals("B114") || tmpHeader.transType.equals("B115") || tmpHeader.transType.equals("B116")) {
            reflectType = "ElecBillTrans";
            tmpHeader.pckType = PacketType.Ele;
        } else if (tmpHeader.transType.equals("Bat101") || tmpHeader.transType.equals("Bat101Qry") || tmpHeader.transType.equals("BOB01") || tmpHeader.transType.equals("BOB02") || tmpHeader.transType.equals("BOB03") || tmpHeader.transType.equals("BOB04") || tmpHeader.transType.equals("BOB05") || tmpHeader.transType.equals("BOB06") || tmpHeader.transType.equals("BOB07") || tmpHeader.transType.equals("BOB08") || tmpHeader.transType.equals("BOB09") || tmpHeader.transType.equals("BOB102")) {
            reflectType = "BatchOpenBill";// 光大批量出票
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("BP001") || tmpHeader.transType.equals("BP002") || tmpHeader.transType.equals("BP003") || tmpHeader.transType.equals("BP004") || tmpHeader.transType.equals("BP005") || tmpHeader.transType.equals("BP006") || tmpHeader.transType.equals("BP007")
                || tmpHeader.transType.equals("BP008") || tmpHeader.transType.equals("BP009") || tmpHeader.transType.equals("BP101") || tmpHeader.transType.equals("BP102") || tmpHeader.transType.equals("BP103") || tmpHeader.transType.equals("BP104") || tmpHeader.transType.equals("BP105")
                || tmpHeader.transType.equals("BP106") || tmpHeader.transType.equals("BP107") || tmpHeader.transType.equals("BP108") || tmpHeader.transType.equals("BP109")
                || tmpHeader.transType.equals("B317") || tmpHeader.transType.equals("B318") || tmpHeader.transType.equals("B319") || tmpHeader.transType.equals("B320") || tmpHeader.transType.equals("B321")
                || tmpHeader.transType.equals("BP901") || tmpHeader.transType.equals("BP902") || tmpHeader.transType.equals("BP903") || tmpHeader.transType.equals("BP904") || tmpHeader.transType.equals("BP905")) {
            reflectType = "BillPool";           //票据池
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("CPTQ") || tmpHeader.transType.equals("CPAQ") || tmpHeader.transType.equals("CPASQ")) {
            reflectType = "CashPool";       //民生银行现金池
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("LCIssueApp") || tmpHeader.transType.equals("LCIssueAppEdit") || tmpHeader.transType.equals("DisConfirm") || tmpHeader.transType.equals("OrderHonour")
                || tmpHeader.transType.equals("OrderHonourEdit") || tmpHeader.transType.equals("OrderPay") || tmpHeader.transType.equals("Dishonor") || tmpHeader.transType.equals("ChargeBackApply")) {
            reflectType = "ImportLC";
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("PayCurRate")) {//外汇汇率查询
            reflectType = "ExchangeRate";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("1908") || tmpHeader.transType.equals("1944") || tmpHeader.transType.equals("6908") || tmpHeader.transType.equals("6944") || tmpHeader.transType.equals("1908BAT") || tmpHeader.transType.equals("1944BAT") || tmpHeader.transType.equals("7527") || "SubmitTransferOrder".equals(tmpHeader.transType) || "QueryTransferPay".equals(tmpHeader.transType)) {
            reflectType = "SinglePay";
            if (tmpHeader.transType.equals("1908") || tmpHeader.transType.equals("6908") || tmpHeader.transType.equals("1908BAT") || tmpHeader.transType.equals("7527") || "SubmitTransferOrder".equals(tmpHeader.transType)) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("4005") || tmpHeader.transType.equals("4006")) {
            //活期转定期
            reflectType = "CurrTransPeriod";
            if (tmpHeader.transType.equals("4005")) {
                tmpHeader.pckType = PacketType.Other;
            } else {
                tmpHeader.pckType = PacketType.OtherQuery;
            }
        } else if (tmpHeader.transType.equals("9108") || tmpHeader.transType.equals("9144")) {
            reflectType = "RealTime";
            if (tmpHeader.transType.equals("9108")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("PurchaseFCP") || tmpHeader.transType.equals("PurchaseFCSQ")) {//购汇
            reflectType = "PurchaseExchange";
            if (tmpHeader.transType.equals("PurchaseFCP")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("SettleFCP") || tmpHeader.transType.equals("SettleFCSQ")) {//结汇
            reflectType = "SettlementExchange";
            if (tmpHeader.transType.equals("SettleFCP")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("DomesticFCP") || tmpHeader.transType.equals("CrossborderFCP") || tmpHeader.transType.equals("OutsideFCP") ||
                tmpHeader.transType.equals("DomesticFCSQ") || tmpHeader.transType.equals("CrossborderFCSQ") || tmpHeader.transType.equals("OutsideFCSQ")) {//外币付款
            reflectType = "ForeignCurrSinglePay";
            if (tmpHeader.transType.equals("DomesticFCP") || tmpHeader.transType.equals("CrossborderFCP") || tmpHeader.transType.equals("OutsideFCP")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("RealAuth") || tmpHeader.transType.equals("RealAuthQuery")) {
            reflectType = "Authentication";
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("9110") || tmpHeader.transType.equals("9146")) {
            reflectType = "SMSRec";
            if (tmpHeader.transType.equals("9110")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("9109") || tmpHeader.transType.equals("9145")) {
            reflectType = "IvrRec";
            if (tmpHeader.transType.equals("9109")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("1988") || tmpHeader.transType.equals("1988-ReSend") || tmpHeader.transType.equals("1998") || tmpHeader.transType.equals("9188") || tmpHeader.transType.equals("9188-ReSend") || tmpHeader.transType.equals("9198")) {
            reflectType = "BatPayRec";
            if ("RefundInsu01".equals(tmpHeader.commandCode)) {
                reflectType = "BatRecRefund";
            }
            if (tmpHeader.transType.equals("1988") || tmpHeader.transType.equals("9188") || tmpHeader.transType.equals("1988-ReSend") || tmpHeader.transType.equals("9188-ReSend")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("9208") || tmpHeader.transType.equals("9288") || tmpHeader.transType.equals("9244")) {
            reflectType = "Withhold";
            if (tmpHeader.transType.equals("9244") && ("ABC02".equals(tmpHeader.bankCode) || "CCB04".equals(tmpHeader.bankCode))) {
                reflectType = "BatPayRec";
            }
            if (tmpHeader.transType.equals("9208") || tmpHeader.transType.equals("9288")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("GenQRInfo") || tmpHeader.transType.equals("SubmitQROrder") || tmpHeader.transType.equals("QueryQRPay")) {
            reflectType = "QRPay";
            if (tmpHeader.transType.equals("SubmitQROrder")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("SubmitH5Order") || tmpHeader.transType.equals("QueryH5Pay")) {
            reflectType = "H5Order";
            if (tmpHeader.transType.equals("SubmitH5Order")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if ("SubmitAPPOrder".equalsIgnoreCase(tmpHeader.transType) || "QueryAPPPay".equalsIgnoreCase(tmpHeader.transType)) {
            reflectType = "AppOrder";
            if ("SubmitAPPOrder".equalsIgnoreCase(tmpHeader.transType)) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("SubmitJSAPIOrder") || tmpHeader.transType.equals("SubmitWXMiniProgOrder") || tmpHeader.transType.equals("SubmitMiniProgOrder") || tmpHeader.transType.equals("QueryMiniProgPay") || tmpHeader.transType.equals("QueryJSAPIPay") || tmpHeader.transType.equals("GenGetUserCodeURL") || "GetUserId".equals(tmpHeader.transType) || tmpHeader.transType.equals("GetRealNameAuthURL")) {
            reflectType = "JSAPIOrder";
            if (tmpHeader.transType.equals("SubmitJSAPIOrder") || tmpHeader.transType.equals("SubmitWXMiniProgOrder") || tmpHeader.transType.equals("SubmitMiniProgOrder")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("CloseOrder") || tmpHeader.transType.equals("CloseQROrder") || tmpHeader.transType.equals("CloseGWOrder") || tmpHeader.transType.equals("CloseJSAPIOrder") || tmpHeader.transType.equals("CloseAPPOrder") || tmpHeader.transType.equals("CloseH5Order") || tmpHeader.transType.equals("CloseMiniProgOrder")) {
            reflectType = "CloseOrder";
            tmpHeader.pckType = PacketType.CloseOrder;
        } else if (tmpHeader.transType.equals("QryStatement") || "ROA".equals(tmpHeader.transType)) {
            reflectType = "Statement";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("SendSmsCode") || tmpHeader.transType.equals("CheckSmsCode")) {

            reflectType = "SendSmsCode";
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("GenGwMap") || tmpHeader.transType.equals("GWPAY") || tmpHeader.transType.equals("QueryGwOrder")) { // 网关支付
            reflectType = "Gateway";
            if (tmpHeader.transType.equals("GenGwMap") || tmpHeader.transType.equals("GWPAY")) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("ENDIIMPT") || tmpHeader.transType.equals("QENDIIMPT") || tmpHeader.transType.equals("QueryRecAuthInfo")) {
            reflectType = "AuthorizeForRec";
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("CancCont") || tmpHeader.transType.equals("QryCancCont") || tmpHeader.transType.equals("QueryRecAuthCancelInfo")) {
            reflectType = "AuthorizeCancelForRec";
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("5001") || tmpHeader.transType.toUpperCase().equals("REFUNDTICKET")) {
            reflectType = "QryRefund";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("5002") || tmpHeader.transType.toUpperCase().equals("DOWNLOADRECEIPT")) {
            reflectType = "Receipt";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("SubmitRefundRec".equalsIgnoreCase(tmpHeader.transType) || "QueryRefundRec".equalsIgnoreCase(tmpHeader.transType)) {
            reflectType = "RecRefund";
            if ("SubmitRefundRec".equalsIgnoreCase(tmpHeader.transType)) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if ("SubmitBatRefundRec".equalsIgnoreCase(tmpHeader.transType) || "QueryBatRefundRec".equalsIgnoreCase(tmpHeader.transType)) {
            reflectType = "BatRecRefund";
            if ("SubmitBatRefundRec".equalsIgnoreCase(tmpHeader.transType)) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if (tmpHeader.transType.equals("Contract") || tmpHeader.transType.equals("QryContract") || tmpHeader.transType.equals("QryBatContract") || tmpHeader.transType.equals("UpContract")) {
            reflectType = "Contract";
            tmpHeader.pckType = PacketType.Other;
        } else if (tmpHeader.transType.equals("DeContract") || tmpHeader.transType.equals("QryDeContract")) {
            reflectType = "DeContract";
            tmpHeader.pckType = PacketType.Other;
        } else if ("SubmitEntrust".equals(tmpHeader.transType) || "SubmitDeEntrust".equals(tmpHeader.transType) || "QueryEntrust".equals(tmpHeader.transType)) {
            reflectType = "Entrust";
            tmpHeader.pckType = PacketType.Other;
        } else if ("SubmitEntrustRec".equals(tmpHeader.transType) || "QueryEntrustRec".equals(tmpHeader.transType)) {
            reflectType = "EntrustRec";
            if ("SubmitEntrustRec".equals(tmpHeader.transType)) {
                tmpHeader.pckType = PacketType.Pay;
            } else {
                tmpHeader.pckType = PacketType.PayQuery;
            }
        } else if ("SubmitVirtualOrder".equals(tmpHeader.transType) || "QueryVirtualPay".equals(tmpHeader.transType)) {
            reflectType = "VirtualOrder";
            tmpHeader.pckType = PacketType.PayQuery;
        } else if ("QueryAppId".equals(tmpHeader.transType)) {
            reflectType = "GetAppId";
            tmpHeader.pckType = PacketType.Other;
        } else if ("QrySmsRecUserInfo".equals(tmpHeader.transType)) {
            reflectType = "QryUserInfo";
            tmpHeader.pckType = PacketType.Other;
        } else if ("AQ01".equals(tmpHeader.transType)) {
            reflectType = "QuoteCheck";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("FX01".equals(tmpHeader.transType)) {
            reflectType = "ForeignExchange";
            tmpHeader.pckType = PacketType.Other;
        } else if ("FX02".equals(tmpHeader.transType)) {
            reflectType = "ForeignExchange";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("QrySubAccount".equals(tmpHeader.transType)) {
            reflectType = "SubAccount";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("UpdateSubAccount".equals(tmpHeader.transType)) {
            reflectType = "SubAccount";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("QryQuotaInfo".equals(tmpHeader.transType)) {
            reflectType = "QryQuotaInfo";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("QryFinanceRecInfo".equals(tmpHeader.transType)) {
            reflectType = "QryFinanceRecInfo";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("QryInCustodyInfo".equals(tmpHeader.transType)) {
            reflectType = "QryInCustodyInfo";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("QryUndueBillInfo".equals(tmpHeader.transType)) {
            reflectType = "QryUndueBillInfo";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("OrderMsg")) {
            reflectType = "OrderMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if (tmpHeader.transType.equals("MailedMsg")) {
            reflectType = "MailedMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("PrivateSaleMsg".equals(tmpHeader.transType)) {
            reflectType = "PrivateSaleMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("PrivateMoveMsg".equals(tmpHeader.transType)) {
            reflectType = "PrivateMoveMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("InvoiceMsg".equals(tmpHeader.transType)) {
            reflectType = "InvoiceMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("RetailMsg".equals(tmpHeader.transType)) {
            reflectType = "RetailMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("RetailStockMsg".equals(tmpHeader.transType)) {
            reflectType = "RetailStockMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("CertificateMailedMsg".equals(tmpHeader.transType)) {
            reflectType = "CertificateMailedMsg";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("AuditAccount".equals(tmpHeader.transType)) {
            reflectType = "AuditAccount";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("TransactionReplenish".equals(tmpHeader.transType)) {
            reflectType = "TransactionReplenish";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("8710".equals(tmpHeader.transType)) {
            reflectType = "PushInfoToBank";
            tmpHeader.pckType = PacketType.Other;
        } else if ("IQ01".equals(tmpHeader.transType)) {
            reflectType = "ForeignCurrCheck";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("IQ02".equals(tmpHeader.transType)) {
            reflectType = "ForeignCurrCheck";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("IS01".equals(tmpHeader.transType)) {
            reflectType = "ForeignCurrencyCJ";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("IQ03".equals(tmpHeader.transType)) {
            reflectType = "ForeignCurrencyCJ";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("AQ02".equals(tmpHeader.transType)) {
            reflectType = "CodeFile";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else if ("RelationDN".equals(tmpHeader.transType)) {
            reflectType = "RelationDN";
            tmpHeader.pckType = PacketType.OtherQuery;
        } else {
            reflectType = "OtherElse";
            tmpHeader.pckType = PacketType.Other;
        }

        String reflectDirectBank = tmpHeader.bankCode;
        if (tmpHeader.bankCode.startsWith("FnGrd") && tmpHeader.bankCode.length() == 8) {
            reflectDirectBank = "FnGrd01";
        }
        return "com.fingard.dsp.bank.directbank." + reflectDirectBank.toLowerCase() + "." + reflectDirectBank + reflectType;
    }

    public HashMap<String, String> dealDirectTrans(HashMap<String, String> p_hashMap) {
        HashMap<String, String> retMap = null;
        StringBuilder sbLog = new StringBuilder();
        ReqRespHeader tmpHeader = new ReqRespHeader();
        Date startTime = new Date();
        Date logTime = null;
        try {
            sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 1.接收ATS的请求：\r\n");
            Iterator<String> iter = p_hashMap.keySet().iterator();
            while (iter.hasNext()) {
                String eachKey = iter.next();
                sbLog.append(eachKey + ":" + p_hashMap.get(eachKey) + "\r\n");
            }
            sbLog.append("\r\n\r\n");

            if (p_hashMap.containsKey("BankCode")) {
                tmpHeader.bankCode = p_hashMap.get("BankCode");
            }
            if (p_hashMap.containsKey("TransType")) {
                tmpHeader.transType = p_hashMap.get("TransType");
            }
            if (p_hashMap.containsKey("Entity")) {
                tmpHeader.corporation = p_hashMap.get("Entity");
            }
            if (p_hashMap.containsKey("SystemCode")) {
                tmpHeader.group = p_hashMap.get("SystemCode");
            }
            if (p_hashMap.containsKey("CommandCode")) {
                tmpHeader.commandCode = p_hashMap.get("CommandCode");
            }
            if (p_hashMap.containsKey("TransSeqID")) {
                tmpHeader.transSeqID = p_hashMap.get("TransSeqID");
            }
            if (p_hashMap.containsKey("RdSeq")) {
                tmpHeader.reqSeqID = p_hashMap.get("RdSeq");
                tmpHeader.reqSeqOrBatNo = tmpHeader.reqSeqID;
            }
            if (p_hashMap.containsKey("OurBankAccount")) {
                tmpHeader.ownAct = p_hashMap.get("OurBankAccount");
            }
            if (p_hashMap.containsKey("OrderType")) {
                tmpHeader.orderType = p_hashMap.get("OrderType");
            }
            if (p_hashMap.containsKey("LogTransID")) {
                tmpHeader.logTransID = p_hashMap.get("LogTransID");
            }

            boolean isMatched = true;
            if (StringHelper.hasAnyChar(FGBiz.dspCenter.dspSet.enableSimulate) && ("true".equalsIgnoreCase(FGBiz.dspCenter.dspSet.enableSimulate) || FGBiz.dspCenter.dspSet.enableSimulate.contains("," + p_hashMap.get("BankCode") + ","))) {
                try {
                    String tmpRetFile = StringHelper.trimEnd(FGBiz.dspCenter.dspSet.simulataFilePath, File.separator) + File.separator + "dsp-config/MapSimulate" + File.separator + tmpHeader.bankCode + File.separator + tmpHeader.transType;
                    File tmpFile = new File(tmpRetFile);
                    if (tmpFile.exists()) {
                        isMatched = false;
                        sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 当前已开启挡板...\r\n\r\n");
                        sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 挡板文件路径: " + tmpRetFile + "\r\n\r\n");
                        retMap = new HashMap<String, String>();
                        String tmpMapFileContent = FileHelper.readToString(tmpFile, "UTF-8");
                        sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 挡板文件内容:\r\n" + tmpMapFileContent + "\r\n\r\n");

                        StringReader strReader = new StringReader(tmpMapFileContent);
                        BufferedReader tmpReader = new BufferedReader(strReader);

                        while (true) {
                            String eachline = tmpReader.readLine();
                            if (eachline == null) {
                                break;
                            }
                            int index = eachline.indexOf(":");
                            if (index >= 0) {
                                String key = eachline.substring(0, eachline.indexOf(":"));
                                String value = eachline.substring(eachline.indexOf(":") + 1);
                                if (value.contains("{$")) {
                                    String targetNode = value.substring(2, value.lastIndexOf("}"));
                                    if (p_hashMap.containsKey(targetNode)) {
                                        value = p_hashMap.get(targetNode);
                                    }
                                }
                                retMap.put(key, value.trim());
                            }
                        }
                        if (retMap.size() == 0) {
                            retMap.put("RespCode", "-1");
                            retMap.put("RespInfo", "挡板文件[" + tmpRetFile + "]内容为空，无法解析,请检查挡板文件内容是否合规.");
                            sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + "挡板文件[" + tmpRetFile + "]内容为空，无法解析,请检查挡板文件内容是否合规.\r\n\r\n");
                        }
                    } else {
                        sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 当前未开启挡板,原因：本地挡板文件路径:[ + " + tmpRetFile + "]不存在!\r\n\r\n");
                        sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 开始进行正常请求...\r\n\r\n");
                    }

                    /*HashMap<String, String> retHashMap = new HashMap<String, String>();

                    Random random = new Random();
                    int max = 5;
                    int min = 2;

                    String transState = String.valueOf(random.nextInt(max) % (max - min + 1) + min);

                    if (p_hashMap.get("TransType").equals("9146")) {
                        retHashMap.put("RespCode", "0");
                        retHashMap.put("RespInfo", "");
                        retHashMap.put("RdSeq", p_hashMap.get("RdSeq"));
                        retHashMap.put("TransState", transState);
                        retHashMap.put("PayInfoCode", "0");
                        retHashMap.put("OutTransID", "3241324134");
                        retHashMap.put("NeedLimit", "");
                    }

                    if (p_hashMap.get("TransType").equals("QueryQRPay") || p_hashMap.get("TransType").equals("QueryGwOrder") || p_hashMap.get("TransType").equals("QueryJSAPIPay")) {
                        retHashMap.put("RespCode", "0");
                        retHashMap.put("RespInfo", "");
                        retHashMap.put("RdSeq", p_hashMap.get("RdSeq"));
                        retHashMap.put("OppBank", "");
                        retHashMap.put("TransState", transState);
                        retHashMap.put("PayInfoCode", "0");
                        retHashMap.put("OutTransID", "3432434");
                        retHashMap.put("OpenId", "");
                        retHashMap.put("OppBankAccount", "32432423432442323");
                    }

                    return retHashMap;*/
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }

            if (isMatched) {
                String respCode = "";
                String respInfo = "";

                String className = getClassName(tmpHeader);
                BankFront tmpBankFront = getBankFront(tmpHeader);
                if ((tmpHeader.transType != null && tmpHeader.transType.equals("VerifySign")) || tmpBankFront != null) {
                    String reqPayID = "";
                    boolean needRemove = false;
                    PayQryController payQryCtrl = FGBiz.dspCenter.getPayQryController();
                    try {
                        Class<?> bankClass = Class.forName(className);
                        if (bankClass != null) {
                            DirectBase tmpDirectBase = (DirectBase) bankClass.newInstance();
                            tmpDirectBase.reqHeader = tmpHeader;
                            tmpDirectBase.bankFront = tmpBankFront;
                            tmpDirectBase.setSbLog(sbLog);


                            StringBuilder sbChk = new StringBuilder();
                            boolean isChked = true;
                            if (tmpHeader.pckType == PacketType.PayQuery) {
                                isChked = tmpDirectBase.checkBankPayOverTime(p_hashMap, sbChk);
                            }

                            //如果是支付提交，则此时记录，在finally里释放
                            //如果是状态查询，则此时判断该笔交易是否还在处理中
                            if (isChked && (PacketType.Pay.equals(tmpHeader.pckType) || PacketType.PayQuery.equals(tmpHeader.pckType))) {
                                reqPayID = tmpHeader.reqSeqOrBatNo;
                                if (StringHelper.hasAnyChar(reqPayID)) {
                                    reqPayID = StringHelper.joinNotEmpty("-", tmpHeader.tenant, tmpHeader.bankCode, reqPayID);
                                    if (PacketType.Pay.equals(tmpHeader.pckType)) {
                                        payQryCtrl.putPayReqID(reqPayID);
                                        needRemove = true;//执行完成后，需移除
                                    } else {
                                        isChked = payQryCtrl.checkNotExistsPayReqID(reqPayID);
                                        if (isChked == false) {
                                            sbChk.append("请求流水号" + tmpHeader.reqSeqOrBatNo + "正在提交处理中，请再次查询");
                                        }
                                    }
                                }
                            }

                            if (tmpHeader.transType.equals("GenQRInfo")) {
                                ReqGenQRInfo reqGenQR = new ReqGenQRInfo(p_hashMap, tmpHeader);
                                IQRPay iQRPay = (IQRPay) tmpDirectBase;
                                RetAtsGenQRInfo retGen = iQRPay.genQRInfo(reqGenQR);
                                retMap = retGen.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("GenGetUserCodeURL") || "GetUserId".equals(tmpHeader.transType)) {
                                ReqGenGetUserCodeURL reqGenURL = new ReqGenGetUserCodeURL(p_hashMap, tmpHeader);
                                IJSAPIOrder iJsApi = (IJSAPIOrder) tmpDirectBase;
                                RetAtsGenGetUserCodeURL retGen = null;
                                if (tmpHeader.transType.equals("GenGetUserCodeURL")) {
                                    retGen = iJsApi.GenGetUserCodeURL(reqGenURL);
                                } else {
                                    retGen = iJsApi.getUserId(reqGenURL);
                                }
                                retMap = retGen.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("GetRealNameAuthURL")) {
                                ReqGenRealNameURL reqGenURL = new ReqGenRealNameURL(p_hashMap, tmpHeader);
                                IJSAPIOrder iJsApi = (IJSAPIOrder) tmpDirectBase;
                                RetAtsGenRealNameURL retGen = iJsApi.genRealNameURL(reqGenURL);
                                retMap = retGen.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("GenGwMap") || tmpHeader.transType.equals("GWPAY")) {
                                ReqGateway reqGateway = new ReqGateway(p_hashMap, tmpHeader);
                                IGateway iGateway = (IGateway) tmpDirectBase;
                                HashMap<String, String> respMap = iGateway.GenGwMap(reqGateway);
                                retMap = respMap;
                            } else if (tmpHeader.transType.equals("QueryGwOrder")) {
                                RetAtsQueryOrder retAts = null;
                                if (isChked) {
                                    ReqQueryOrder reqQry = new ReqQueryOrder(p_hashMap, tmpHeader);
                                    IGateway iGateway = (IGateway) tmpDirectBase;
                                    retAts = iGateway.queryGWPay(reqQry);
                                } else {
                                    retAts = new RetAtsQueryOrder();
                                    retAts.respCode = "-1";
                                    retAts.respInfo = sbChk.toString();
                                }
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("SubmitQROrder")) {
                                ReqUnifiedOrder tmpReq = new ReqUnifiedOrder(p_hashMap, tmpHeader);
                                IQRPay iQRPay = (IQRPay) tmpDirectBase;
                                RetAtsUnifiedOrder retAts = iQRPay.submitQROrder(tmpReq);
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("QueryQRPay")) {
                                RetAtsQueryOrder retAts = null;
                                if (isChked) {
                                    ReqQueryOrder reqQry = new ReqQueryOrder(p_hashMap, tmpHeader);
                                    IQRPay iQRPay = (IQRPay) tmpDirectBase;
                                    retAts = iQRPay.queryQRPay(reqQry);

                                } else {
                                    retAts = new RetAtsQueryOrder();
                                    retAts.respCode = "-1";
                                    retAts.respInfo = sbChk.toString();
                                }
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("SubmitH5Order")) {
                                ReqUnifiedOrder tmpReq = new ReqUnifiedOrder(p_hashMap, tmpHeader);
                                IH5Order iH5Order = (IH5Order) tmpDirectBase;
                                RetAtsUnifiedOrder retAts = iH5Order.submitH5Order(tmpReq);
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("QueryH5Pay")) {
                                RetAtsQueryOrder retAts = null;
                                if (isChked) {
                                    ReqQueryOrder reqQry = new ReqQueryOrder(p_hashMap, tmpHeader);
                                    IH5Order iH5Order = (IH5Order) tmpDirectBase;
                                    retAts = iH5Order.queryH5Pay(reqQry);
                                } else {
                                    retAts = new RetAtsQueryOrder();
                                    retAts.respCode = "-1";
                                    retAts.respInfo = sbChk.toString();
                                }
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("SubmitAPPOrder")) {
                                ReqUnifiedOrder tmpReq = new ReqUnifiedOrder(p_hashMap, tmpHeader);
                                IAppOrder iAppOrder = (IAppOrder) tmpDirectBase;
                                RetAtsUnifiedOrder retAts = iAppOrder.submitAppOrder(tmpReq);
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("QueryAPPPay")) {
                                RetAtsQueryOrder retAts = null;
                                if (isChked) {
                                    ReqQueryOrder reqQry = new ReqQueryOrder(p_hashMap, tmpHeader);
                                    IAppOrder iAppOrder = (IAppOrder) tmpDirectBase;
                                    retAts = iAppOrder.queryAppPay(reqQry);
                                } else {
                                    retAts = new RetAtsQueryOrder();
                                    retAts.respCode = "-1";
                                    retAts.respInfo = sbChk.toString();
                                }
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("SubmitJSAPIOrder") || tmpHeader.transType.equals("SubmitWXMiniProgOrder") || tmpHeader.transType.equals("SubmitMiniProgOrder")) {
                                ReqUnifiedOrder tmpReq = new ReqUnifiedOrder(p_hashMap, tmpHeader);
                                IJSAPIOrder iJSAPIOrder = (IJSAPIOrder) tmpDirectBase;
                                RetAtsUnifiedOrder retAts = iJSAPIOrder.submitJSAPIOrder(tmpReq);
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("QueryJSAPIPay") || tmpHeader.transType.equals("QueryMiniProgPay")) {
                                RetAtsQueryOrder retAts = null;
                                if (isChked) {
                                    ReqQueryOrder reqQry = new ReqQueryOrder(p_hashMap, tmpHeader);
                                    IJSAPIOrder iJSAPIOrder = (IJSAPIOrder) tmpDirectBase;
                                    retAts = iJSAPIOrder.queryJSAPIPay(reqQry);
                                } else {
                                    retAts = new RetAtsQueryOrder();
                                    retAts.respCode = "-1";
                                    retAts.respInfo = sbChk.toString();
                                }
                                retMap = retAts.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("CloseOrder") || tmpHeader.transType.equals("CloseQROrder") || tmpHeader.transType.equals("CloseGWOrder") || tmpHeader.transType.equals("CloseJSAPIOrder") || tmpHeader.transType.equals("CloseAPPOrder") || tmpHeader.transType.equals("CloseH5Order") || tmpHeader.transType.equals("CloseMiniProgOrder")) {
                                ReqCloseOrder tmpReq = new ReqCloseOrder(p_hashMap, tmpHeader);
                                ICloseOrder iCloseOrder = (ICloseOrder) tmpDirectBase;
                                RetAtsCloseOrder retAts = iCloseOrder.closeOrder(tmpReq);
                                retMap = retAts.getRetAtsHashMap();
                            } else if ("6908".equalsIgnoreCase(tmpHeader.transType) || "SubmitTransferOrder".equalsIgnoreCase(tmpHeader.transType)) {
                                ReqSingle tmpReq1908 = new ReqSingle(p_hashMap, tmpHeader);
                                if (isChked) {
                                    ISinglePay iSinglePay = (ISinglePay) tmpDirectBase;
                                    RetAtsSingle retAts = iSinglePay.d_1908_SglPay(tmpReq1908);
                                    retMap = retAts.getRetAtsHashMap();
                                } else {
                                    RetAtsSingle retAts = new RetAtsSingle(tmpReq1908.reqHeader);
                                    RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                                    tmpRetDetail.respInfo = sbChk.toString();
                                    tmpRetDetail.reqSeqID = tmpReq1908.singleDetail.askNumber;
                                    if (tmpHeader.isReSend) {//是重发
                                        tmpRetDetail.respCode = "-1";
                                    } else {
                                        tmpRetDetail.respCode = "0";
                                        tmpRetDetail.transState = PaymentState.FAIL_Payment;
                                        tmpRetDetail.payInfoCode = "E1301";
                                    }
                                    retAts.writeRetDetail(tmpRetDetail);
                                    retMap = retAts.getRetAtsHashMap();
                                }
                            } else if (tmpHeader.transType.equals("9144")) {
                                RetAtsSingle tmpRet9144 = null;
                                if (isChked) {
                                    ReqQrySingle tmpReq9144 = new ReqQrySingle(p_hashMap, tmpHeader);
                                    IRealTime iRealTime2 = (IRealTime) tmpDirectBase;
                                    tmpRet9144 = iRealTime2.d_9144_QryRealTimeRec(tmpReq9144);
                                } else {
                                    tmpRet9144 = new RetAtsSingle(tmpHeader);
                                    RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                                    tmpRetDetail.respCode = "-1";
                                    tmpRetDetail.respInfo = sbChk.toString();
                                    tmpRet9144.writeRetDetail(tmpRetDetail);
                                }
                                retMap = tmpRet9144.getRetAtsHashMap();
                            } else if ("QueryTransferPay".equalsIgnoreCase(tmpHeader.transType) || "6944".equalsIgnoreCase(tmpHeader.transType)) {
                                RetAtsSingle tmpRet6944 = null;
                                if (isChked) {
                                    ReqQrySingle tmpReq6944 = new ReqQrySingle(p_hashMap, tmpHeader);
                                    ISinglePay iSinglePay2 = (ISinglePay) tmpDirectBase;
                                    tmpRet6944 = iSinglePay2.d_1944_QrySglPay(tmpReq6944);
                                } else {
                                    tmpRet6944 = new RetAtsSingle(tmpHeader);
                                    RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                                    tmpRetDetail.respCode = "-1";
                                    tmpRetDetail.respInfo = sbChk.toString();
                                    tmpRet6944.writeRetDetail(tmpRetDetail);
                                }
                                retMap = tmpRet6944.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("9145")) {
                                RetAtsSingle tmpRet9145 = null;
                                if (isChked) {
                                    ReqQrySingle tmpReq9145 = new ReqQrySingle(p_hashMap, tmpHeader);
                                    IIvrRec iQryIvrRec = (IIvrRec) tmpDirectBase;
                                    tmpRet9145 = iQryIvrRec.d_9145_QryIvrRec(tmpReq9145);
                                } else {
                                    tmpRet9145 = new RetAtsSingle(tmpHeader);
                                    RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                                    tmpRetDetail.respCode = "-1";
                                    tmpRetDetail.respInfo = sbChk.toString();
                                    tmpRet9145.writeRetDetail(tmpRetDetail);
                                }
                                retMap = tmpRet9145.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("9146")) {
                                RetAtsSingle tmpRet9146 = null;
                                if (isChked) {
                                    ReqQrySingle tmpReq9146 = new ReqQrySingle(p_hashMap, tmpHeader);
                                    ISMSRec iSMSRec2 = (ISMSRec) tmpDirectBase;
                                    tmpRet9146 = iSMSRec2.d_9146_QrySMSRec(tmpReq9146);
                                } else {
                                    tmpRet9146 = new RetAtsSingle(tmpHeader);
                                    RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                                    tmpRetDetail.respCode = "-1";
                                    tmpRetDetail.respInfo = sbChk.toString();
                                    tmpRet9146.writeRetDetail(tmpRetDetail);
                                }
                                retMap = tmpRet9146.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("RealAuth")) {
                                ReqAuth tmpReqAuth = new ReqAuth(p_hashMap, tmpHeader);
                                IAuthentication iAuth = (IAuthentication) tmpDirectBase;
                                RetAtsAuth tmpRetAuth = iAuth.dealAuth(tmpReqAuth);
                                retMap = tmpRetAuth.getRetAtsHashMap();
                            } else if (tmpHeader.transType.equals("RealAuthQuery")) {
                                ReqQryAuth tmpReqQueryAuth = new ReqQryAuth(p_hashMap, tmpHeader);
                                IAuthentication iAuth = (IAuthentication) tmpDirectBase;
                                RetAtsAuth tmpRetAts = iAuth.dealQryAuth(tmpReqQueryAuth);
                                retMap = tmpRetAts.getRetAtsHashMap();
                            } else if ("SubmitRefundRec".equalsIgnoreCase(tmpHeader.transType)) {
                                ReqRecRefund tmpReqRefund = new ReqRecRefund(p_hashMap, tmpHeader);
                                IRecRefund ireqRef = (IRecRefund) tmpDirectBase;
                                RetAtsRecRefund tmpRetAuth = ireqRef.submitRecRefund(tmpReqRefund);
                                retMap = tmpRetAuth.getRetAtsHashMap();
                            } else if ("QueryRefundRec".equalsIgnoreCase(tmpHeader.transType)) {
                                ReqQryRecRefund tmpReqQryRecRef = new ReqQryRecRefund(p_hashMap, tmpHeader);
                                IRecRefund irecRefund = (IRecRefund) tmpDirectBase;
                                RetAtsQryRecRefund tmpRetAts = irecRefund.queryRecRefund(tmpReqQryRecRef);
                                retMap = tmpRetAts.getRetAtsHashMap();
                            } else if ("SubmitEntrust".equals(tmpHeader.transType)) {
                                ReqEntrust reqEntrust = new ReqEntrust(p_hashMap, tmpHeader);
                                IEntrust iEntrust = (IEntrust) tmpDirectBase;
                                RetAtsEntrust retEntrust = iEntrust.submitEntrust(reqEntrust);
                                retMap = retEntrust.getRetAtsHashMap();
                            } else if ("SubmitDeEntrust".equals(tmpHeader.transType)) {
                                ReqDeEntrust reqDeEntrust = new ReqDeEntrust(p_hashMap, tmpHeader);
                                IEntrust iDeEntrust = (IEntrust) tmpDirectBase;
                                RetAtsDeEntrust retDeEntrust = iDeEntrust.submitDeEntrust(reqDeEntrust);
                                retMap = retDeEntrust.getRetAtsHashMap();
                            } else if ("QueryEntrust".equals(tmpHeader.transType)) {
                                ReqQueryEntrust reqQryEntrust = new ReqQueryEntrust(p_hashMap, tmpHeader);
                                IEntrust iEntrust = (IEntrust) tmpDirectBase;
                                RetAtsQueryEntrust retQryEntrust = iEntrust.queryEntrust(reqQryEntrust);
                                retMap = retQryEntrust.getRetAtsHashMap();
                            } else if ("SubmitEntrustRec".equals(tmpHeader.transType)) {
                                ReqEntrustRec reqEntrust = new ReqEntrustRec(p_hashMap, tmpHeader);
                                IEntrustRec iEntrust = (IEntrustRec) tmpDirectBase;
                                RetAtsEntrustRec retEntrust = iEntrust.submitEntrustRec(reqEntrust);
                                retMap = retEntrust.getRetAtsHashMap();
                            } else if ("QueryEntrustRec".equals(tmpHeader.transType)) {
                                ReqQueryEntrustRec reqEntrust = new ReqQueryEntrustRec(p_hashMap, tmpHeader);
                                IEntrustRec iEntrust = (IEntrustRec) tmpDirectBase;
                                RetAtsQueryEntrustRec retEntrust = iEntrust.queryEntrustRec(reqEntrust);
                                retMap = retEntrust.getRetAtsHashMap();
                            } else if ("SubmitVirtualOrder".equals(tmpHeader.transType)) {
                                ReqVirtualOrder reqVirtualOrder = new ReqVirtualOrder(p_hashMap, tmpHeader);
                                IVirtualOrder iVirtualOrder = (IVirtualOrder) tmpDirectBase;
                                RetAtsVirtualOrder retVirtualOrder = iVirtualOrder.submitVirtualOrder(reqVirtualOrder);
                                retMap = retVirtualOrder.getRetAtsHashMap();
                            } else if ("QueryVirtualPay".equals(tmpHeader.transType)) {
                                ReqQueryVirtualOrder reqQueryVirtualOrder = new ReqQueryVirtualOrder(p_hashMap, tmpHeader);
                                IVirtualOrder iQueryVirtualOrder = (IVirtualOrder) tmpDirectBase;
                                RetAtsQueryVirtualOrder retQueryVirtualOrder = iQueryVirtualOrder.queryVirtualPay(reqQueryVirtualOrder);
                                retMap = retQueryVirtualOrder.getRetAtsHashMap();
                            } else if ("QueryAppId".equals(tmpHeader.transType)) {
                                ReqQueryGetAppId reqGetAppId = new ReqQueryGetAppId(p_hashMap, tmpHeader);
                                IGetAppID iGetAppID = (IGetAppID) tmpDirectBase;
                                RetAtsQueryGetAppId retGetAppId = iGetAppID.queryGetAppId(reqGetAppId);
                                retMap = retGetAppId.getRetAtsHashMap();
                            } else {
                                ReqOtherElse reqElse = new ReqOtherElse(p_hashMap, tmpHeader);
                                IOtherElse iOther = (IOtherElse) tmpDirectBase;
                                RetAtsOtherElse retOther = iOther.d_else(reqElse);
                                retMap = retOther.getRetAtsHashMap();
                            }
                        } else {
                            respCode = "-1";
                            respInfo = tmpHeader.bankCode + "未实现接口" + tmpHeader.transType;
                        }
                    } catch (Throwable e) {
                        //e.printStackTrace();
                        respCode = "-1";
                        respInfo = e.getMessage();
                        FGBiz.limitMsg.exception(getLogCode(tmpHeader, "dealDirectTrans"), e);
                    } finally {
                        if (needRemove) {
                            payQryCtrl.removePayReqID(reqPayID);
                        }
                    }
                } else {
                    respCode = "-1";
                    respInfo = "没有符合要求的前置机!";
                }

                if (retMap == null) {
                    retMap = new HashMap<String, String>();
                    retMap.put("RespCode", respCode);
                    retMap.put("RespInfo", respInfo);
                }
            }

            Date tmpTimeNow = new Date();
            logTime = tmpTimeNow;
            sbLog.append(Format.DateTimeSSSFormat.format(tmpTimeNow) + " 4.返回ATS的响应：\r\n");
            Iterator<String> iter2 = retMap.keySet().iterator();
            while (iter2.hasNext()) {
                String eachKey2 = iter2.next();
                sbLog.append(eachKey2 + ":" + retMap.get(eachKey2) + "\r\n");
            }
            sbLog.append("\r\n");
        } catch (Throwable t) {
            sbLog.append("\r\n" + LogHelper.getStackTrace(t) + "\r\n");
            FGBiz.limitMsg.exception(getLogCode(tmpHeader, "dealDirectTrans"), t);
            if (retMap == null) {
                retMap = new HashMap<String, String>();
                retMap.put("RespCode", "-1");
                retMap.put("RespInfo", LogHelper.getStackTrace(t));
            }
        }
        try {
            LogHelper.writeBankLog(_idHelper.getNextID(), startTime, logTime, "", tmpHeader, sbLog);
        } catch (Exception e) {
            FGBiz.limitMsg.exception("LogHelper.writeBankLog", e, getLogCode(tmpHeader, "dealDirectTrans"), sbLog.toString());
        }
        return retMap;
    }

    private String getLogCode(ReqRespHeader pHeader, String pDefVal) {
        String retVal = "";
        if (pHeader != null) {
            retVal = StringHelper.joinNotEmpty(".", pHeader.bankCode, pHeader.transType);
        }
        if (StringHelper.isNullOrEmpty(retVal)) {
            return pDefVal;
        } else {
            return retVal;
        }
    }

    /**
     * 处理直联请求
     *
     * @param p_bizO
     * @param tmpHeader
     * @param xmlReader
     * @return 返回值为报文中的内容
     * @throws Exception
     */
    public String dealDirectTrans(RequestNIO p_bizO, ReqRespHeader tmpHeader, XmlTextReader xmlReader) throws Exception {
        String tmpRespBody = "";

        if (tmpHeader.transType.equals("RefreshBankConfig")) {
            HashSet<String> hashBkCode = new HashSet<String>();
            hashBkCode.add(tmpHeader.bankCode);
            String refreshMsg = FGBiz.refreshBankConfig(hashBkCode);
            return "<ATSYH><TransResp><TransParam><RespCode>0</RespCode><RespInfo>" + XmlHelper.encodeFull(refreshMsg) + "</RespInfo></TransParam></TransResp></ATSYH>";
        } else if (FGBiz.tenantServer.isEnable()) {
            //启用了远程调用租户端，判断是否调用远程租户端
            if (FGBiz.tenantServer.isRemoting(tmpHeader.tenant)) {
                try {
                    return FGBiz.tenantServer.remotingInvoke(tmpHeader.tenant, xmlReader.getOriXmlString());
                } catch (Throwable e) {
                    return "<ATSYH><TransResp><TransParam><RespCode>-1</RespCode><RespInfo>" + LogHelper.getStackTrace(e) + "</RespInfo></TransParam></TransResp></ATSYH>";
                }
            }
        }

        if (StringHelper.hasAnyChar(FGBiz.dspCenter.dspSet.enableSimulate) && ("true".equalsIgnoreCase(FGBiz.dspCenter.dspSet.enableSimulate) || FGBiz.dspCenter.dspSet.enableSimulate.contains("," + tmpHeader.bankCode + ","))) {
            try {
                Simulate simu = new Simulate(p_bizO);
                ExecResponse resp = simu.getSimulateStr(xmlReader, tmpHeader);
                if (resp.isSucceed) {
                    boolean useSleepSimulate = FGBiz.dspCenter.dspSet.useSleepSimulate;
                    p_bizO.sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 挡板返回是否增加睡眠等待时间延迟返回ATS：" + useSleepSimulate + "\r\n");
                    if (useSleepSimulate) {
                        p_bizO.sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 挡板返回是否增加睡眠等待时间延迟返回ATS启动成功...\r\n");
                        synchronized (this) {
                            p_bizO.sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 睡眠等待时间:" + FGBiz.dspCenter.dspSet.sleepSecondsSimulate + "秒\r\n");
                            Thread.sleep(new Double(FGBiz.dspCenter.dspSet.sleepSecondsSimulate * 1000).longValue());
                        }
                        p_bizO.sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 睡眠结束,开始返回ATS...\r\n\r\n");
                    } else {
                        p_bizO.sbLog.append(Format.DateTimeSSSFormat.format(new Date()) + " 当前挡板暂不启用等待时间延迟,开始返回ATS...\r\n\r\n");
                    }
                    tmpRespBody = resp.getResultAsString();
                    return tmpRespBody;
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

        String cmpTransType = tmpHeader.transType;
        if (StringHelper.hasAnyChar(cmpTransType)) {
            cmpTransType = cmpTransType.toLowerCase();
        }
        if ("getbankfrontstatus".equals(cmpTransType)) {
            return FGBiz.dspCenter.getBankFrontStatus(p_bizO, tmpHeader, oriAtsReqStr);
        } else if ("getstartlog".equals(cmpTransType)) {
            return "<ATSYH><TransResp><TransParam><RespCode>0</RespCode><RespInfo>" + FGBiz.startLog.getLog() + "</RespInfo></TransParam></TransResp></ATSYH>";
        } else if ("getdsplog".equals(cmpTransType)) {
            return FGBiz.dspCenter.getDSPLog(p_bizO, tmpHeader, oriAtsReqStr);
        }

        List<String> reqSeqID = new ArrayList<String>();
        String bgnDate = "";
        String className = getClassName(tmpHeader);
        if (!DSPSecurityData.getInstance().isReadFileFlag()) {
            if ((tmpHeader.pckType == PacketType.Pay || tmpHeader.pckType == PacketType.PayQuery)) {
                bgnDate = xmlReader.getSimpleText("BgnDate");
                if (StringHelper.isNullOrEmpty(bgnDate)) {
                    bgnDate = xmlReader.getSimpleTextNotNull("PayDate") + " " + xmlReader.getSimpleTextNotNull("PayTime");
                }
                String tmpReqSeqID = "";
                //TODO DSP2.0 确认ATS单笔支付提交时为何上上ReqBatchNO字段，并且查询时又不送ReqBatchNO字段
                if (ENDSPTransType.SINGLE_PAY_SUBMIT.code().equals(tmpHeader.transType) || ENDSPTransType.SINGLE_PAY_QUERY.code().equals(tmpHeader.transType)) {
                    while (xmlReader.read(detailReqSeqIDPath)) {
                        tmpReqSeqID = xmlReader.readedXElement.getSingleText("ReqSeqID");
                        if (!StringHelper.isNullOrEmpty(tmpReqSeqID)) {
                            reqSeqID.add(tmpReqSeqID);
                        }
                    }
                } else {
                    //批量支付
                    tmpReqSeqID = xmlReader.getSimpleText("ReqBatchNO");
                    if (!StringHelper.isNullOrEmpty(tmpReqSeqID)) {
                        reqSeqID.add(tmpReqSeqID);
                    }
                }
                xmlReader.backToTop();
            }
        }
        String returnMsg = getBankFront(tmpHeader.pckType, reqSeqID, bgnDate);
        if (returnMsg != null) {
            tmpRespBody = setErrorResp(returnMsg, tmpHeader.transType);
            return tmpRespBody;
        }
        BankFront tmpBankFront = getBankFront(tmpHeader);
        if (tmpBankFront != null) {
            tmpHeader.bankFrontCode = tmpBankFront.code;

            try {
                if (!tmpHeader.bankCode.startsWith("FnGrd") && !tmpHeader.bankCode.equals(tmpBankFront.bankCode)) {
                    throw new Exception("查找前置有误，请核对请求！");
                }
                if ("DOWNLOADRECEIPT".equalsIgnoreCase(tmpHeader.transType)) {
                    //回单下载，采用Pro版本
                    ReceiptPro rPro = new ReceiptPro(p_bizO, tmpBankFront, tmpHeader);
                    RetAtsBase tmpRetAts = rPro.execReceiptDown(className, xmlReader);
                    return tmpRetAts.getRetAtsString();
                }
                if ("7516".equalsIgnoreCase(tmpHeader.transType) && FGBiz.dspCenter.qryByEachDay7516) {
                    //按日查询历史明细，按日进行本地缓存
                    TransactionPro tPro = new TransactionPro(p_bizO, tmpBankFront, tmpHeader);
                    RetAtsBase tmpRetAts = tPro.qryByEachDay(className, xmlReader);
                    return tmpRetAts.getRetAtsString();
                }

                Class<?> bankClass = null;
                boolean useDirectchannelJarFile = "true".equalsIgnoreCase(tmpBankFront.useDirectchannelJarFile);
                if (useDirectchannelJarFile) {
                    /*动态加载指定jar包调用其中某个类的方法*/
                    FGBiz.dynamicClassLoader.sbLog = p_bizO.sbLog;
                    FGBiz.dynamicClassLoader.recordVersion(p_bizO.sbLog, className);
                    bankClass = new DynamicClassLoader().loadClass(className);
                } else {
                    bankClass = Class.forName(className);
                }

                if (bankClass != null) {
                    String directchannelClassName = directchannelClassName = CommandNameMap.commandAndNameMapping.get(tmpHeader.transType);

                    DirectBase tmpDirectBase = (DirectBase) SpringContextHolder.getBean(tmpHeader.bankCode + directchannelClassName);
                    tmpDirectBase.reqHeader = tmpHeader;
                    tmpDirectBase.bankFront = tmpBankFront;
                    tmpDirectBase.seqIDInner = p_bizO.seqIDInner;
                    tmpDirectBase.setSbLog(p_bizO.sbLog);
                    tmpDirectBase.setLogFlushTime(p_bizO.connTime);
                    StringBuilder sbChk = new StringBuilder();
                    boolean isChked = tmpDirectBase.checkBankPayOverTime(xmlReader, sbChk);
                    if (isChked) {
                        if ((tmpHeader.pckType == PacketType.Pay || tmpHeader.pckType == PacketType.PayQuery)) {
                            isChked = tmpDirectBase.checkBankPayInfo(tmpHeader.pckType, bgnDate, tmpBankFront.urid, tmpHeader.transType, reqSeqID, sbChk);
                        }
                    }

                    RetAtsBase tmpRetAts = null;
                    if (tmpHeader.transType.equals("7503")) {
                        Req7503BalQry tmpReq7503 = new Req7503BalQry(xmlReader, tmpHeader);
                        IVirtualAccount iVirtualAccount = (IVirtualAccount) tmpDirectBase;
                        tmpRetAts = iVirtualAccount.d_7503_BalQry(tmpReq7503);
                    } else if (tmpHeader.transType.equals("7504")) {

                    } else if (tmpHeader.transType.equals("7506")) {
                        Req7506BalQry tmpReq7506 = new Req7506BalQry(xmlReader, tmpHeader);
                        IBalance iBalance = (IBalance) tmpDirectBase;
                        tmpRetAts = iBalance.d_7506_BalQry(tmpReq7506);
                    } else if (tmpHeader.transType.equals("7505")) {
                        Req7505HisBalQry tmpReq7505 = new Req7505HisBalQry(xmlReader, tmpHeader);
                        IBalance iBalance = (IBalance) tmpDirectBase;
                        tmpRetAts = iBalance.d_7505_BalQry(tmpReq7505);
                    } else if ("7507".equals(tmpHeader.transType)) {
                        Req7507DepQry tmpReq7507 = new Req7507DepQry(xmlReader, tmpHeader);
                        IDeposit iDeposit = (IDeposit) tmpDirectBase;
                        tmpRetAts = iDeposit.d_7507_DepQry(tmpReq7507);
                    } else if (tmpHeader.transType.equals("7516")) {
                        Req7516HisTrans tmpReq7516 = new Req7516HisTrans(xmlReader, tmpHeader);
                        if (!StringHelper.isNullOrEmpty(tmpReq7516.isSpecialAct) && tmpReq7516.isSpecialAct.equals("1")) {
                            boolean isSuccess = TransHelper.updateAutoTrans(false, false, tmpReq7516.actNum);
                            RetAtsTrans retAts = new RetAtsTrans(tmpReq7516.reqHeader);
                            retAts.writeStart();
                            retAts.writeRespCode(isSuccess ? "0" : "-1");
                            retAts.writeRespInfo(isSuccess ? "禁用自动触发历史明细成功！" : "禁用失败，请重试！");
                            retAts.writeEnd();
                            tmpRetAts = retAts;
                        } else {
                            ITransaction iTransaction = (ITransaction) tmpDirectBase;
                            if (FGBiz.dspCenter.enableCacheHisTrans && !String.valueOf(tmpReq7516.isReqFromDsp).equals("1") && !tmpReq7516.reqHeader.bankCode.contains("BOCOM01")) {

                                List<RetAtsTransDetail> tmpDetails = TransHelper.getHisTransCache(tmpReq7516.actNum, tmpReq7516.dateFrom, tmpReq7516.dateTo);
                                if (tmpDetails.size() > 0) {
                                    RetAtsTrans retAts = new RetAtsTrans(tmpReq7516.reqHeader);
                                    retAts.hasSorted = true;
                                    retAts.writeStart();
                                    for (RetAtsTransDetail tmpDetail : tmpDetails) {
                                        retAts.writeRetDetail(tmpDetail);
                                    }
                                    if (retAts.getWrittenRdCount() == 0) {
                                        retAts.writeRespCode("0");
                                        retAts.writeRespInfo("交易为空");
                                    }
                                    retAts.writeEndWithoutInsertDB();
                                    tmpRetAts = retAts;
                                } else {
                                    tmpRetAts = iTransaction.d_7516_HisTrans(tmpReq7516);
                                }
                            } else {
                                tmpRetAts = iTransaction.d_7516_HisTrans(tmpReq7516);
                            }
                            if (FGBiz.dspCenter.enableAutoHisTrans && ((RetAtsTrans) tmpRetAts).getWrittenRdCount() > 0) {
                                TransHelper.insertOrUpdateActInfo(false, tmpHeader.bankCode, tmpHeader.corporation, tmpHeader.group, tmpReq7516.actNum, tmpReq7516.actCur, tmpReq7516.actArea);
                            }
                        }
                    } else if (tmpHeader.transType.equals("7515")) {
                        Req7515TodayTrans tmpReq7515 = new Req7515TodayTrans(xmlReader, tmpHeader);
                        if (!StringHelper.isNullOrEmpty(tmpReq7515.isSpecialAct) && tmpReq7515.isSpecialAct.equals("1")) {
                            boolean isSuccess = TransHelper.updateAutoTrans(true, false, tmpReq7515.actNum);
                            RetAtsTrans retAts = new RetAtsTrans(tmpReq7515.reqHeader);
                            retAts.writeStart();
                            retAts.writeRespCode(isSuccess ? "0" : "-1");
                            retAts.writeRespInfo(isSuccess ? "禁用自动触发当日明细成功！" : "禁用失败，请重试！");
                            retAts.writeEnd();
                            tmpRetAts = retAts;
                        } else {
                            ITransaction iTransaction = (ITransaction) tmpDirectBase;
                            if (FGBiz.dspCenter.enableAutoTodayTrans && !String.valueOf(tmpReq7515.isReqFromDsp).equals("1") && !StringHelper.isNullOrEmpty(tmpReq7515.queryUrid)) {

                                List<RetAtsTransDetail> tmpDetails = TransHelper.getCurTransCache(tmpReq7515.actNum, Format.Date8Format.format(new Date()), Integer.parseInt(tmpReq7515.queryUrid));
                                if (tmpDetails.size() > 0) {
                                    RetAtsTrans retAts = new RetAtsTrans(tmpReq7515.reqHeader);
                                    retAts.hasSorted = true;
                                    retAts.writeStart();

                                    for (RetAtsTransDetail tmpDetail : tmpDetails) {
                                        retAts.writeRetDetail(tmpDetail);
                                    }
                                    if (retAts.getWrittenRdCount() == 0) {
                                        retAts.writeRespCode("0");
                                        retAts.writeRespInfo("交易为空");
                                    }
                                    retAts.writeEndWithoutInsertDB();
                                    tmpRetAts = retAts;
                                } else {
                                    iTransaction.d_7515_TodayTrans(tmpReq7515);

                                    tmpDetails = TransHelper.getCurTransCache(tmpReq7515.actNum, Format.Date8Format.format(new Date()), Integer.parseInt(tmpReq7515.queryUrid));
                                    RetAtsTrans retAts = new RetAtsTrans(tmpReq7515.reqHeader);
                                    retAts.hasSorted = true;
                                    retAts.writeStart();

                                    for (RetAtsTransDetail tmpDetail : tmpDetails) {
                                        retAts.writeRetDetail(tmpDetail);
                                    }
                                    if (retAts.getWrittenRdCount() == 0) {
                                        retAts.writeRespCode("0");
                                        retAts.writeRespInfo("交易为空");
                                    }
                                    retAts.writeEndWithoutInsertDB();
                                    tmpRetAts = retAts;
                                }
                            } else {
                                tmpRetAts = iTransaction.d_7515_TodayTrans(tmpReq7515);
                            }
                            if (FGBiz.dspCenter.enableAutoTodayTrans && ((RetAtsTrans) tmpRetAts).getWrittenRdCount() > 0) {
                                TransHelper.insertOrUpdateActInfo(true, tmpHeader.bankCode, tmpHeader.corporation, tmpHeader.group, tmpReq7515.actNum, tmpReq7515.actCur, tmpReq7515.actArea);
                            }
                        }
                    } else if (tmpHeader.transType.equals("7508")) {//余额对账信息查询接口
                        ReqBalCheckQry tmpReq7508 = new ReqBalCheckQry(xmlReader, tmpHeader);
                        IBalanceCheck iBalanceCheck = (IBalanceCheck) tmpDirectBase;
                        tmpRetAts = iBalanceCheck.d_7508_BalCheck(tmpReq7508);
                    } else if (tmpHeader.transType.equals("7509")) {//余额对账确认提交结果接口
                        ReqBalCheckConfirmQry tmpReq7509 = new ReqBalCheckConfirmQry(xmlReader, tmpHeader);
                        IBalanceCheckConfirm iBalanceCheckConfirm = (IBalanceCheckConfirm) tmpDirectBase;
                        tmpRetAts = iBalanceCheckConfirm.d_7509_BalCheckConfirm(tmpReq7509);
                    } else if (tmpHeader.transType.equals("1908") || tmpHeader.transType.equals("6908") || tmpHeader.transType.equals("7527")) {
                        String reqBatNO = xmlReader.getSimpleText("ReqBatchNO");
                        boolean is1908Bat = false;
                        if (reqBatNO != null) {
                            is1908Bat = true;
                            if (reqBatNO.length() == 0) {
                                isChked = false;
                                sbChk.append("ReqBatchNO值不能为空");
                            }
                        }
                        if (!is1908Bat) {
                            int drCount = xmlReader.countElement(RequestBase.PATH_Detail);
                            if (drCount > 1) {
                                isChked = false;
                                sbChk.append("单笔合批ReqBatchNO不能为空");
                            }
                        }
                        if (is1908Bat) {//合批
                            ReqSingleBat tmpReq1908BAT = new ReqSingleBat(xmlReader, tmpHeader);
                            if (isChked) {
                                ISinglePay iSinglePay = (ISinglePay) tmpDirectBase;
                                tmpRetAts = iSinglePay.d_1908BAT_SglBatPay(tmpReq1908BAT);
                            } else {
                                RetAtsSingleBat retAts = new RetAtsSingleBat(tmpReq1908BAT.reqHeader);
                                retAts.totalNum = tmpReq1908BAT.totalNum;
                                retAts.totalAmt = tmpReq1908BAT.totalAmt;
                                retAts.reqBatchNO = tmpReq1908BAT.reqBatchNO;
                                retAts.batRespInfo = sbChk.toString();
                                if (tmpHeader.isReSend) {
                                    retAts.batRespCode = "-1";
                                } else {
                                    retAts.batRespCode = "0";
                                    retAts.batTransState = PaymentState.FAIL_Payment;
                                    retAts.batPayInfoCode = "E1301";
                                }
                                retAts.writeBeforeDetail();
                                retAts.writeAfterDetail();
                                tmpRetAts = retAts;
                            }
                        } else {
                            ReqSingle tmpReq1908 = new ReqSingle(xmlReader, tmpHeader);
                            if (isChked) {
                                ISinglePay iSinglePay = (ISinglePay) tmpDirectBase;
                                tmpRetAts = iSinglePay.d_1908_SglPay(tmpReq1908);
                            } else {
                                RetAtsSingle retAts = new RetAtsSingle(tmpReq1908.reqHeader);
                                RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                                tmpRetDetail.respInfo = sbChk.toString();
                                tmpRetDetail.reqSeqID = tmpReq1908.singleDetail.askNumber;
                                if (tmpHeader.isReSend) {//是重发
                                    tmpRetDetail.respCode = "-1";
                                } else {
                                    tmpRetDetail.respCode = "0";
                                    tmpRetDetail.transState = PaymentState.FAIL_Payment;
                                    tmpRetDetail.payInfoCode = "E1301";
                                }
                                retAts.writeRetDetail(tmpRetDetail);
                                tmpRetAts = retAts;
                            }
                        }

                    } else if (tmpHeader.transType.equals("1908BAT")) {
                        ReqSingleBat tmpReq1908BAT = new ReqSingleBat(xmlReader, tmpHeader);
                        if (isChked) {
                            ISinglePay iSinglePay = (ISinglePay) tmpDirectBase;
                            tmpRetAts = iSinglePay.d_1908BAT_SglBatPay(tmpReq1908BAT);
                        } else {
                            RetAtsSingleBat retAts = new RetAtsSingleBat(tmpReq1908BAT.reqHeader);
                            retAts.totalNum = tmpReq1908BAT.totalNum;
                            retAts.totalAmt = tmpReq1908BAT.totalAmt;
                            retAts.reqBatchNO = tmpReq1908BAT.reqBatchNO;
                            retAts.batRespInfo = sbChk.toString();
                            if (tmpHeader.isReSend) {//是重发
                                retAts.batRespCode = "-1";
                            } else {
                                retAts.batRespCode = "0";
                                retAts.batTransState = PaymentState.FAIL_Payment;
                                retAts.batPayInfoCode = "E1301";
                            }

                            retAts.writeBeforeDetail();
                            retAts.writeAfterDetail();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("4005")) {
                        Req4005 tmpReq4005 = new Req4005(xmlReader, tmpHeader);
                        if (isChked) {
                            ICurrTransPeriod icurrTransPeriod = (ICurrTransPeriod) tmpDirectBase;
                            tmpRetAts = icurrTransPeriod.currTransPeriod(tmpReq4005);
                        } else {
                            RetAtsCurrTransPer retAts = new RetAtsCurrTransPer(tmpReq4005.reqHeader);
                            RetAtsCurrTransPerDetail tmpRetAtsDetail = new RetAtsCurrTransPerDetail();
                            tmpRetAtsDetail.respCode = "0";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            tmpRetAtsDetail.reqSeqID = tmpReq4005.singleDetail.askNumber;
                            tmpRetAtsDetail.transState = PaymentState.FAIL_Payment;
                            tmpRetAtsDetail.payInfoCode = "E1301";
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("4006")) {
                        Req4006 tmpReq4006 = new Req4006(xmlReader, tmpHeader);
                        if (isChked) {
                            ICurrTransPeriod icurrTransPeriod = (ICurrTransPeriod) tmpDirectBase;
                            tmpRetAts = icurrTransPeriod.qryCurrTransPeriod(tmpReq4006);
                        } else {
                            RetAtsCurrTransPer retAts = new RetAtsCurrTransPer(tmpReq4006.reqHeader);
                            RetAtsCurrTransPerDetail tmpRetAtsDetail = new RetAtsCurrTransPerDetail();
                            tmpRetAtsDetail.respCode = "-1";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("FX01")) {
                        ReqFX01 tmpReq1024 = new ReqFX01(xmlReader, tmpHeader);
                        if (isChked) {
                            IForeignExchange iForeignExchange = (IForeignExchange) tmpDirectBase;
                            tmpRetAts = iForeignExchange.foreignExchange(tmpReq1024);
                        } else {
                            RetAtsForeignCurrency retAts = new RetAtsForeignCurrency(tmpReq1024.reqHeader);
                            RetAtsForeignCurrencyDetail tmpRetAtsDetail = new RetAtsForeignCurrencyDetail();
                            tmpRetAtsDetail.respCode = "0";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            tmpRetAtsDetail.reqSeqID = tmpReq1024.singleDetail.askNumber;
                            tmpRetAtsDetail.transState = PaymentState.FAIL_Payment;
                            tmpRetAtsDetail.payInfoCode = "E1301";
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("QrySubAccount")) {
                        ReqQrySubAccount tmpReq = new ReqQrySubAccount(xmlReader, tmpHeader);
                        ISubAccount iSubAccount = (ISubAccount) tmpDirectBase;
                        tmpRetAts = iSubAccount.querySubAccountInfo(tmpReq);
                    } else if (tmpHeader.transType.equals("UpdateSubAccount")) {
                        ReqUpdateSubAccount tmpReq = new ReqUpdateSubAccount(xmlReader, tmpHeader);
                        ISubAccount iSubAccount = (ISubAccount) tmpDirectBase;
                        tmpRetAts = iSubAccount.maintenanceSubAccountInfo(tmpReq);
                    } else if (tmpHeader.transType.equals("FX02")) {
                        ReqFX02 tmpReq1025 = new ReqFX02(xmlReader, tmpHeader);
                        if (isChked) {
                            IForeignExchange iForeignExchange = (IForeignExchange) tmpDirectBase;
                            tmpRetAts = iForeignExchange.qryForeignExchange(tmpReq1025);
                        } else {
                            RetAtsForeignCurrency retAts = new RetAtsForeignCurrency(tmpReq1025.reqHeader);
                            RetAtsForeignCurrencyDetail tmpRetAtsDetail = new RetAtsForeignCurrencyDetail();
                            tmpRetAtsDetail.respCode = "-1";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("1944") || tmpHeader.transType.equals("6944")) {
                        String reqBatNO = xmlReader.getSimpleText("ReqBatchNO");
                        boolean is1944Bat = false;
                        if (reqBatNO != null) {
                            is1944Bat = true;
                            if (reqBatNO.length() == 0) {
                                isChked = false;
                                sbChk.append("ReqBatchNO值不能为空");
                            }
                        }
                        if (!is1944Bat) {
                            int drCount = xmlReader.countElement(RequestBase.PATH_Detail);
                            if (drCount > 1) {
                                isChked = false;
                                sbChk.append("单笔合批查询ReqBatchNO不能为空");
                            }
                        }
                        if (is1944Bat) {//合批查询
                            ReqQrySingleBat tmpReq1944BAT = new ReqQrySingleBat(xmlReader, tmpHeader);
                            if (isChked) {
                                ISinglePay iSinglePay = (ISinglePay) tmpDirectBase;
                                tmpRetAts = iSinglePay.d_1944BAT_QrySglBatPay(tmpReq1944BAT);
                            } else {
                                RetAtsSingleBat retAts = new RetAtsSingleBat(tmpReq1944BAT.reqHeader);
                                retAts.reqBatchNO = tmpReq1944BAT.reqBatchNO;
                                retAts.batRespCode = "-1";
                                retAts.batRespInfo = sbChk.toString();
                                retAts.writeBeforeDetail();
                                retAts.writeAfterDetail();
                                tmpRetAts = retAts;
                            }
                        } else {
                            ReqQrySingle tmpReq1944 = new ReqQrySingle(xmlReader, tmpHeader);
                            if (isChked) {
                                ISinglePay iSinglePay2 = (ISinglePay) tmpDirectBase;
                                tmpRetAts = iSinglePay2.d_1944_QrySglPay(tmpReq1944);
                            } else {
                                RetAtsSingle retAts = new RetAtsSingle(tmpReq1944.reqHeader);

                                RetAtsSglDetail tmpRetAtsDetail = new RetAtsSglDetail();
                                tmpRetAtsDetail.respCode = "-1";
                                tmpRetAtsDetail.respInfo = sbChk.toString();
                                retAts.writeRetDetail(tmpRetAtsDetail);
                                tmpRetAts = retAts;
                            }
                        }
                    } else if (tmpHeader.transType.equals("1944BAT")) {
                        ReqQrySingleBat tmpReq1944BAT = new ReqQrySingleBat(xmlReader, tmpHeader);
                        if (isChked) {
                            ISinglePay iSinglePay = (ISinglePay) tmpDirectBase;
                            tmpRetAts = iSinglePay.d_1944BAT_QrySglBatPay(tmpReq1944BAT);
                        } else {
                            RetAtsSingleBat retAts = new RetAtsSingleBat(tmpReq1944BAT.reqHeader);
                            retAts.reqBatchNO = tmpReq1944BAT.reqBatchNO;
                            retAts.batRespCode = "-1";
                            retAts.batRespInfo = sbChk.toString();
                            retAts.writeBeforeDetail();
                            retAts.writeAfterDetail();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9108")) {
                        ReqSingle tmpReq9108 = new ReqSingle(xmlReader, tmpHeader);
                        if (isChked) {
                            IRealTime iRealTime = (IRealTime) tmpDirectBase;
                            tmpRetAts = iRealTime.d_9108_RealTimeRec(tmpReq9108);
                        } else {
                            RetAtsSingle retAts = new RetAtsSingle(tmpReq9108.reqHeader);
                            RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                            if (tmpHeader.isReSend) {//是重发
                                tmpRetDetail.respCode = "-1";
                            } else {
                                tmpRetDetail.respCode = "0";
                                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                                tmpRetDetail.payInfoCode = "E1301";
                            }

                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReq9108.singleDetail.askNumber;

                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("RealAuth")) {
                        ReqAuth tmpReqAuth = new ReqAuth(xmlReader, tmpHeader);
                        if (isChked) {
                            IAuthentication iAuth = (IAuthentication) tmpDirectBase;
                            tmpRetAts = iAuth.dealAuth(tmpReqAuth);
                        } else {
                            RetAtsAuth retAts = new RetAtsAuth(tmpReqAuth.reqHeader);
                            RetAtsAuthDetail tmpRetDetail = new RetAtsAuthDetail();

                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReqAuth.authDetail.askNumber;
                            tmpRetDetail.verifyState = VerifyState.FAIL;

                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("RealAuthQuery")) {
                        ReqQryAuth tmpReqAuth = new ReqQryAuth(xmlReader, tmpHeader);
                        if (isChked) {
                            IAuthentication iAuth = (IAuthentication) tmpDirectBase;
                            tmpRetAts = iAuth.dealQryAuth(tmpReqAuth);
                        } else {
                            RetAtsAuth retAts = new RetAtsAuth(tmpReqAuth.reqHeader);

                            RetAtsAuthDetail tmpRetAtsDetail = new RetAtsAuthDetail();
                            tmpRetAtsDetail.respCode = "-1";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9144")) {
                        ReqQrySingle tmpReq9144 = new ReqQrySingle(xmlReader, tmpHeader);
                        if (isChked) {
                            IRealTime iRealTime2 = (IRealTime) tmpDirectBase;
                            tmpRetAts = iRealTime2.d_9144_QryRealTimeRec(tmpReq9144);
                        } else {
                            RetAtsSingle retAts = new RetAtsSingle(tmpReq9144.reqHeader);

                            RetAtsSglDetail tmpRetAtsDetail = new RetAtsSglDetail();
                            tmpRetAtsDetail.respCode = "-1";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9109")) {//IVR
                        ReqSingle tmpReq9109 = new ReqSingle(xmlReader, tmpHeader);
                        if (isChked) {
                            IIvrRec iIvrRec = (IIvrRec) tmpDirectBase;
                            tmpRetAts = iIvrRec.d_9109_IvrRec(tmpReq9109);
                        } else {
                            RetAtsSingle retAts = new RetAtsSingle(tmpReq9109.reqHeader);
                            RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReq9109.singleDetail.askNumber;
                            tmpRetDetail.transState = PaymentState.FAIL_Payment;
                            tmpRetDetail.payInfoCode = "E1301";
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9145")) {//IVR
                        ReqQrySingle tmpReq9145 = new ReqQrySingle(xmlReader, tmpHeader);
                        if (isChked) {
                            IIvrRec iQryIvrRec = (IIvrRec) tmpDirectBase;
                            tmpRetAts = iQryIvrRec.d_9145_QryIvrRec(tmpReq9145);
                        } else {
                            RetAtsSingle retAts = new RetAtsSingle(tmpReq9145.reqHeader);

                            RetAtsSglDetail tmpRetAtsDetail = new RetAtsSglDetail();
                            tmpRetAtsDetail.respCode = "-1";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9110")) {
                        ReqSMSRec tmpReq9110 = new ReqSMSRec(xmlReader, tmpHeader);
                        if (isChked) {
                            ISMSRec iSMSRec = (ISMSRec) tmpDirectBase;
                            tmpRetAts = iSMSRec.d_9110_SMSRec(tmpReq9110);
                        } else {
                            RetAtsSingle retAts = new RetAtsSingle(tmpReq9110.reqHeader);
                            RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReq9110.singleDetail.askNumber;
                            tmpRetDetail.transState = PaymentState.FAIL_Payment;
                            tmpRetDetail.payInfoCode = "E1301";
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9146")) {
                        ReqQrySingle tmpReq9146 = new ReqQrySingle(xmlReader, tmpHeader);
                        if (isChked) {
                            ISMSRec iSMSRec2 = (ISMSRec) tmpDirectBase;
                            tmpRetAts = iSMSRec2.d_9146_QrySMSRec(tmpReq9146);
                        } else {
                            RetAtsSingle retAts = new RetAtsSingle(tmpReq9146.reqHeader);

                            RetAtsSglDetail tmpRetAtsDetail = new RetAtsSglDetail();
                            tmpRetAtsDetail.respCode = "-1";
                            tmpRetAtsDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetAtsDetail);
                            tmpRetAts = retAts;
                        }
                    } else if ("1988".equals(tmpHeader.transType) || "1988-ReSend".equals(tmpHeader.transType)) {
                        if ("RefundInsu01".equals(tmpHeader.commandCode)) {
                            ReqBatRecRefund tmpReqRefund = new ReqBatRecRefund(xmlReader, tmpHeader);
                            if (isChked) {
                                IBatRecRefund iBatRecRefund = (IBatRecRefund) tmpDirectBase;
                                tmpRetAts = iBatRecRefund.submitBatRecRefund(tmpReqRefund);
                            } else {
                                RetAtsBatPayRec retAts = new RetAtsBatPayRec(tmpReqRefund.reqHeader);
                                if (tmpHeader.isReSend || "1988-ReSend".equals(tmpHeader.transType)) {//是重发
                                    retAts.respCode = "-1";
                                } else {
                                    retAts.respCode = "0";
                                    retAts.transState = PaymentState.FAIL_Batch;
                                    retAts.payInfoCode = "E1301";
                                }

                                retAts.respInfo = sbChk.toString();
                                retAts.reqSeqID = tmpReqRefund.reqBatchNO;

                                retAts.writeRetToATS();
                                tmpRetAts = retAts;
                            }
                        } else {
                            ReqBatPayRec tmpReq1988 = new ReqBatPayRec(xmlReader, tmpHeader);
                            if (isChked) {
                                IBatPayRec iBatPayRec = (IBatPayRec) tmpDirectBase;
                                tmpRetAts = iBatPayRec.d_1988_BatPay(tmpReq1988);
                            } else {
                                RetAtsBatPayRec retAts = new RetAtsBatPayRec(tmpReq1988.reqHeader);
                                if (tmpHeader.isReSend || "1988-ReSend".equals(tmpHeader.transType)) {//是重发
                                    retAts.respCode = "-1";
                                } else {
                                    retAts.respCode = "0";
                                    retAts.transState = PaymentState.FAIL_Batch;
                                    retAts.payInfoCode = "E1301";
                                }

                                retAts.respInfo = sbChk.toString();
                                retAts.reqSeqID = tmpReq1988.reqBatchNO;

                                retAts.writeRetToATS();
                                tmpRetAts = retAts;
                            }
                        }
                    } else if (tmpHeader.transType.equals("1998")) {
                        if ("RefundInsu01".equals(tmpHeader.commandCode)) {
                            ReqQryBatRecRefund tmpReqQryRefund = new ReqQryBatRecRefund(xmlReader, tmpHeader);
                            if (isChked) {
                                IBatRecRefund iBatQryRec = (IBatRecRefund) tmpDirectBase;
                                tmpRetAts = iBatQryRec.queryBatRecRefund(tmpReqQryRefund);
                            } else {
                                RetAtsQryBatRecRefund retAts = new RetAtsQryBatRecRefund(tmpReqQryRefund.reqHeader);
                                retAts.respCode = "-1";
                                retAts.respInfo = sbChk.toString();
                                retAts.writeBeforeDetail();
                                retAts.writeAfterDetail();
                                tmpRetAts = retAts;
                            }
                        } else {
                            ReqQryBatPayRec tmpReq1998 = new ReqQryBatPayRec(xmlReader, tmpHeader);
                            if (isChked) {
                                IBatPayRec iBatPayRec = (IBatPayRec) tmpDirectBase;
                                tmpRetAts = iBatPayRec.d_1998_QryBatPay(tmpReq1998);
                            } else {
                                RetAtsQryBatPayRec retAts = new RetAtsQryBatPayRec(tmpReq1998.reqHeader);
                                retAts.respCode = "-1";
                                retAts.respInfo = sbChk.toString();
                                retAts.writeBeforeDetail();
                                retAts.writeAfterDetail();
                                tmpRetAts = retAts;
                            }
                        }
                    } else if ("9188".equals(tmpHeader.transType) || "9188-ReSend".equals(tmpHeader.transType)) {
                        ReqBatPayRec tmpReq9188 = new ReqBatPayRec(xmlReader, tmpHeader);
                        if (isChked) {
                            IBatPayRec iBatPayRec = (IBatPayRec) tmpDirectBase;
                            tmpRetAts = iBatPayRec.d_9188_BatPay(tmpReq9188);
                        } else {
                            RetAtsBatPayRec retAts = new RetAtsBatPayRec(tmpReq9188.reqHeader);
                            if (tmpHeader.isReSend || "1988-ReSend".equals(tmpHeader.transType)) {//是重发
                                retAts.respCode = "-1";
                            } else {
                                retAts.respCode = "0";
                                retAts.transState = PaymentState.FAIL_Batch;
                                retAts.payInfoCode = "E1301";
                            }

                            retAts.respInfo = sbChk.toString();
                            retAts.reqSeqID = tmpReq9188.reqBatchNO;

                            retAts.writeRetToATS();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9208") || tmpHeader.transType.equals("9288")) {
                        ReqBatPayRec tmpReq9188 = new ReqBatPayRec(xmlReader, tmpHeader);
                        if (isChked) {
                            IWithhold iBatWithhold = (IWithhold) tmpDirectBase;
                            tmpRetAts = iBatWithhold.d_9208_singlePay(tmpReq9188);
                        } else {
                            RetAtsQryBatPayRec retAts = new RetAtsQryBatPayRec(tmpReq9188.reqHeader);
                            retAts.respCode = "-1";
                            retAts.respInfo = sbChk.toString();
                            retAts.writeBeforeDetail();
                            retAts.writeAfterDetail();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9244")) {
                        ReqQryBatPayRec tmpReq9244 = new ReqQryBatPayRec(xmlReader, tmpHeader);
                        if (isChked) {
                            if (tmpHeader.bankCode.equals("ABC02") || tmpHeader.bankCode.equals("CCB04")) {
                                IBatPayRec iBatPayRec = (IBatPayRec) tmpDirectBase;
                                tmpRetAts = iBatPayRec.d_9198_QryBatPay(tmpReq9244);
                            } else {
                                IWithhold iBatWithhold = (IWithhold) tmpDirectBase;
                                tmpRetAts = iBatWithhold.d_9244_QrySinglePay(tmpReq9244);
                            }
                        } else {
                            RetAtsQryBatPayRec retAts = new RetAtsQryBatPayRec(tmpReq9244.reqHeader);
                            retAts.respCode = "-1";
                            retAts.respInfo = sbChk.toString();
                            retAts.writeBeforeDetail();
                            retAts.writeAfterDetail();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("9198")) {
                        ReqQryBatPayRec tmpReq9198 = new ReqQryBatPayRec(xmlReader, tmpHeader);
                        if (isChked) {
                            IBatPayRec iBatPayRec = (IBatPayRec) tmpDirectBase;
                            tmpRetAts = iBatPayRec.d_9198_QryBatPay(tmpReq9198);
                        } else {
                            RetAtsQryBatPayRec retAts = new RetAtsQryBatPayRec(tmpReq9198.reqHeader);
                            retAts.respCode = "-1";
                            retAts.respInfo = sbChk.toString();
                            retAts.writeBeforeDetail();
                            retAts.writeAfterDetail();
                            tmpRetAts = retAts;
                        }
                    } else if ("SubmitBatRefundRec".equals(tmpHeader.transType)) {
                        ReqBatRecRefund tmpReqRefund = new ReqBatRecRefund(xmlReader, tmpHeader);
                        if (isChked) {
                            IBatRecRefund iBatRecRefund = (IBatRecRefund) tmpDirectBase;
                            tmpRetAts = iBatRecRefund.submitBatRecRefund(tmpReqRefund);
                        } else {
                            RetAtsBatPayRec retAts = new RetAtsBatPayRec(tmpReqRefund.reqHeader);
                            retAts.respCode = "0";
                            retAts.respInfo = sbChk.toString();
                            retAts.reqSeqID = tmpReqRefund.reqBatchNO;
                            retAts.transState = PaymentState.FAIL_Batch;
                            retAts.payInfoCode = "E1301";
                            retAts.writeRetToATS();
                            tmpRetAts = retAts;
                        }
                    } else if ("QueryBatRefundRec".equals(tmpHeader.transType)) {
                        ReqQryBatRecRefund tmpReqQryRefund = new ReqQryBatRecRefund(xmlReader, tmpHeader);
                        if (isChked) {
                            IBatRecRefund iBatQryRec = (IBatRecRefund) tmpDirectBase;
                            tmpRetAts = iBatQryRec.queryBatRecRefund(tmpReqQryRefund);
                        } else {
                            RetAtsQryBatRecRefund retAts = new RetAtsQryBatRecRefund(tmpReqQryRefund.reqHeader);
                            retAts.respCode = "-1";
                            retAts.respInfo = sbChk.toString();
                            retAts.writeBeforeDetail();
                            retAts.writeAfterDetail();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("Contract")) {
                        ReqContract tmpReqContract = new ReqContract(xmlReader, tmpHeader);
                        if (isChked) {
                            IContract iContract = (IContract) tmpDirectBase;
                            tmpRetAts = iContract.contract(tmpReqContract);
                        } else {
                            RetAtsContract retAts = new RetAtsContract(tmpReqContract.reqHeader);
                            RetAtsContractDetail tmpRetDetail = new RetAtsContractDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReqContract.contractDetail.askNumber;
                            tmpRetDetail.signState = ContractState.FAIL;
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("QryContract")) {
                        ReqContract tmpReqQryContract = new ReqContract(xmlReader, tmpHeader);
                        if (isChked) {
                            IContract iContract = (IContract) tmpDirectBase;
                            tmpRetAts = iContract.qryContract(tmpReqQryContract);
                        } else {
                            RetAtsContract retAts = new RetAtsContract(tmpReqQryContract.reqHeader);
                            RetAtsContractDetail tmpRetDetail = new RetAtsContractDetail();
                            tmpRetDetail.respCode = "-1";
                            tmpRetDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("QryBatContract")) {
                        ReqQryBatContract tmpReqQryContract = new ReqQryBatContract(xmlReader, tmpHeader);
                        if (isChked) {
                            IContract iContract = (IContract) tmpDirectBase;
                            tmpRetAts = iContract.qryBatContract(tmpReqQryContract);
                        } else {
                            RetAtsQryBatContract retAts = new RetAtsQryBatContract(tmpReqQryContract.reqHeader);
                            RetAtsContractDetail tmpRetDetail = new RetAtsContractDetail();
                            tmpRetDetail.respCode = "-1";
                            tmpRetDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("UpContract")) {
                        ReqContract tmpReqContract = new ReqContract(xmlReader, tmpHeader);
                        if (isChked) {
                            IContract iContract = (IContract) tmpDirectBase;
                            tmpRetAts = iContract.upContract(tmpReqContract);
                        } else {
                            RetAtsContract retAts = new RetAtsContract(tmpReqContract.reqHeader);
                            RetAtsContractDetail tmpRetDetail = new RetAtsContractDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReqContract.contractDetail.askNumber;
                            tmpRetDetail.signState = ContractState.FAIL;
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("DeContract")) {
                        ReqDeContract tmpReqDeContract = new ReqDeContract(xmlReader, tmpHeader);
                        if (isChked) {
                            IDeContract iDeContract = (IDeContract) tmpDirectBase;
                            tmpRetAts = iDeContract.deContract(tmpReqDeContract);
                        } else {
                            RetAtsDeContract retAts = new RetAtsDeContract(tmpReqDeContract.reqHeader);
                            RetAtsDeContractDetail tmpRetDetail = new RetAtsDeContractDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = tmpReqDeContract.contractDetail.askNumber;
                            tmpRetDetail.deSignState = ContractState.FAIL;
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("QryDeContract")) {
                        ReqDeContract tmpReqQryDeContract = new ReqDeContract(xmlReader, tmpHeader);
                        if (isChked) {
                            IDeContract iContractRec = (IDeContract) tmpDirectBase;
                            tmpRetAts = iContractRec.qryDeContract(tmpReqQryDeContract);
                        } else {
                            RetAtsDeContract retAts = new RetAtsDeContract(tmpReqQryDeContract.reqHeader);
                            RetAtsDeContractDetail tmpRetDetail = new RetAtsDeContractDetail();
                            tmpRetDetail.respCode = "-1";
                            tmpRetDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("PurchaseFCP") || tmpHeader.transType.equals("SettleFCP")) {//结汇购汇
                        ReqExchange exchangePay = new ReqExchange(xmlReader, tmpHeader);
                        if (isChked) {
                            ICurrencyExchange iCurrencyExchange = (ICurrencyExchange) tmpDirectBase;
                            tmpRetAts = iCurrencyExchange.exchangePay(exchangePay);
                        } else {
                            RetAtsExchange retAts = new RetAtsExchange(exchangePay.reqHeader);
                            RetAtsExchangeDetail tmpRetDetail = new RetAtsExchangeDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = exchangePay.singleDetail.askNumber;
                            tmpRetDetail.transState = PaymentState.FAIL_Payment;
                            tmpRetDetail.payInfoCode = "E1301";
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("PurchaseFCSQ") || tmpHeader.transType.equals("SettleFCSQ")) {//结汇购汇查询
                        ReqQryExchange qryExchange = new ReqQryExchange(xmlReader, tmpHeader);
                        if (isChked) {
                            ICurrencyExchange iCurrencyExchange = (ICurrencyExchange) tmpDirectBase;
                            tmpRetAts = iCurrencyExchange.qryExchangePay(qryExchange);
                        } else {
                            RetAtsExchange retAts = new RetAtsExchange(qryExchange.reqHeader);
                            RetAtsExchangeDetail tmpRetDetail = new RetAtsExchangeDetail();
                            tmpRetDetail.respCode = "-1";
                            tmpRetDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("DomesticFCP") || tmpHeader.transType.equals("CrossborderFCP") || tmpHeader.transType.equals("OutsideFCP")) {//境内、跨境、全球
                        ReqForeignCurrSingle reqForeignCurrSingle = new ReqForeignCurrSingle(xmlReader, tmpHeader);
                        if (isChked) {
                            IForeignCurrency iForeignCurrency = (IForeignCurrency) tmpDirectBase;
                            tmpRetAts = iForeignCurrency.foreignCurrPay(reqForeignCurrSingle);
                        } else {
                            RetAtsForeignCurrSingle retAts = new RetAtsForeignCurrSingle(reqForeignCurrSingle.reqHeader);
                            RetAtsForeignCurrPayDetail tmpRetDetail = new RetAtsForeignCurrPayDetail();
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.respInfo = sbChk.toString();
                            tmpRetDetail.reqSeqID = reqForeignCurrSingle.singleDetail.askNumber;
                            tmpRetDetail.transState = PaymentState.FAIL_Payment;
                            tmpRetDetail.payInfoCode = "E1301";
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("DomesticFCSQ") || tmpHeader.transType.equals("CrossborderFCSQ") || tmpHeader.transType.equals("OutsideFCSQ")) {//境内、跨境、全球查询
                        ReqQryForeignCurrSingle reqQryForeignCurrSingle = new ReqQryForeignCurrSingle(xmlReader, tmpHeader);
                        if (isChked) {
                            IForeignCurrency iForeignCurrency = (IForeignCurrency) tmpDirectBase;
                            tmpRetAts = iForeignCurrency.qryForeignCurrPay(reqQryForeignCurrSingle);
                        } else {
                            RetAtsForeignCurrSingle retAts = new RetAtsForeignCurrSingle(reqQryForeignCurrSingle.reqHeader);
                            RetAtsForeignCurrPayDetail tmpRetDetail = new RetAtsForeignCurrPayDetail();
                            tmpRetDetail.respCode = "-1";
                            tmpRetDetail.respInfo = sbChk.toString();
                            retAts.writeRetDetail(tmpRetDetail);
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("IQ01")) {
                        ReqCJFrgCurrGetVal reqFrgCurrSingle = new ReqCJFrgCurrGetVal(xmlReader, tmpHeader);
                        IForeignCurrCheck iForeignCurrCheck = (IForeignCurrCheck) tmpDirectBase;
                        tmpRetAts = iForeignCurrCheck.getFrgCurrPayValue(reqFrgCurrSingle);
                    } else if (tmpHeader.transType.equals("IQ02")) {
                        ReqCJFrgCurrCheck reqFrgCurrSingle = new ReqCJFrgCurrCheck(xmlReader, tmpHeader);
                        IForeignCurrCheck iForeignCurrCheck = (IForeignCurrCheck) tmpDirectBase;
                        tmpRetAts = iForeignCurrCheck.checkFrgCurrPayValue(reqFrgCurrSingle);
                    } else if (tmpHeader.transType.equals("IS01")) {
                        ReqCJFrgCurrSingleBat reqFrgCurrSingle = new ReqCJFrgCurrSingleBat(xmlReader, tmpHeader);
                        IForeignCurrencyCJ iForeignCurrCheck = (IForeignCurrencyCJ) tmpDirectBase;
                        tmpRetAts = iForeignCurrCheck.foreignCurrPayCJ_BAT(reqFrgCurrSingle);
                    } else if (tmpHeader.transType.equals("IQ03")) {
                        ReqQryCJFrgCurrSingleBat reqFrgCurrSingle = new ReqQryCJFrgCurrSingleBat(xmlReader, tmpHeader);
                        IForeignCurrencyCJ iForeignCurrCheck = (IForeignCurrencyCJ) tmpDirectBase;
                        tmpRetAts = iForeignCurrCheck.qryForeignCurrPayCJ_BAT(reqFrgCurrSingle);
                    } else if (tmpHeader.transType.equals("AQ02")) {
                        ReqQryCodeFile reqQryCodeFile = new ReqQryCodeFile(xmlReader, tmpHeader);
                        ICodeFile iCodeFile = (ICodeFile) tmpDirectBase;
                        tmpRetAts = iCodeFile.downloadCodeFile(reqQryCodeFile);
                    } else if (tmpHeader.transType.equals("QryStatement") || "ROA".equals(tmpHeader.transType)) {
                        ReqQryStatement tmpReqSttm = new ReqQryStatement(xmlReader, tmpHeader);
                        if (tmpReqSttm.chkBusDate()) {
                            IStatement iStatement = (IStatement) tmpDirectBase;
                            tmpRetAts = iStatement.d_Qry_Statement(tmpReqSttm);
                        } else {
                            RetAtsStatement retAts = new RetAtsStatement(tmpReqSttm);
                            retAts.writeStart();
                            retAts.writeRespCode("-1");
                            retAts.writeRespInfo("查询日期只能小于今天");
                            retAts.writeEnd();
                            tmpRetAts = retAts;
                        }
                    } else if (tmpHeader.transType.equals("SendSmsCode")) {
                        ReqSendSmsCode tmpReqSendSmsCode = new ReqSendSmsCode(xmlReader, tmpHeader);
                        ISendSmsCode iSendSmsCode = (ISendSmsCode) tmpDirectBase;
                        tmpRetAts = iSendSmsCode.sendSmsCode(tmpReqSendSmsCode);
                    } else if (tmpHeader.transType.equals("CheckSmsCode")) {
                        ReqCheckSmsCode tmpReqCheckSmsCode = new ReqCheckSmsCode(xmlReader, tmpHeader);
                        ISendSmsCode iSendSmsCode = (ISendSmsCode) tmpDirectBase;
                        tmpRetAts = iSendSmsCode.checkSmsCode(tmpReqCheckSmsCode);
                    } else if (tmpHeader.transType.equals("QueryJSAPIPay")) {
                        ReqQueryOrder reqQry = new ReqQueryOrder(xmlReader, tmpHeader);
                        IJSAPIOrder iJSAPIOrder = (IJSAPIOrder) tmpDirectBase;
                        RetAtsQueryOrder retAts = iJSAPIOrder.queryJSAPIPay(reqQry);
                        retAts.writeRetAtsXml(tmpHeader);//retMap = retAts.getRetAtsHashMap();
                        tmpRetAts = retAts;
                    } else if (tmpHeader.transType.equals("ENDIIMPT")) {
                        ReqAuthForRec tmpReqAuth4Rec = new ReqAuthForRec(xmlReader, tmpHeader);
                        IAuthorizeForRec iAuth4Rec = (IAuthorizeForRec) tmpDirectBase;
                        tmpRetAts = iAuth4Rec.d_auth(tmpReqAuth4Rec);
                    } else if (tmpHeader.transType.equals("QENDIIMPT")) {
                        ReqQryAuthForRec tmpQryAuth4Rec = new ReqQryAuthForRec(xmlReader, tmpHeader);
                        IAuthorizeForRec iAuth4Rec = (IAuthorizeForRec) tmpDirectBase;
                        tmpRetAts = iAuth4Rec.d_qry_auth(tmpQryAuth4Rec);
                    } else if (tmpHeader.transType.equals("QueryRecAuthInfo")) {
                        ReqQryRecAuthInfo tmpQryRecAuthInfo = new ReqQryRecAuthInfo(xmlReader, tmpHeader);
                        IAuthorizeForRec iAuth4Rec = (IAuthorizeForRec) tmpDirectBase;
                        tmpRetAts = iAuth4Rec.d_qry_authInfo(tmpQryRecAuthInfo);
                    } else if (tmpHeader.transType.equals("CancCont")) {
                        ReqAuthCancelForRec tmpReqAuth4Rec = new ReqAuthCancelForRec(xmlReader, tmpHeader);
                        ICancelAuthorizeForRec iAuth4Rec = (ICancelAuthorizeForRec) tmpDirectBase;
                        tmpRetAts = iAuth4Rec.d_AuthCancel(tmpReqAuth4Rec);
                    } else if (tmpHeader.transType.equals("QryCancCont")) {
                        ReqQryAuthCancelForRec tmpQryAuth4Rec = new ReqQryAuthCancelForRec(xmlReader, tmpHeader);
                        ICancelAuthorizeForRec iAuth4Rec = (ICancelAuthorizeForRec) tmpDirectBase;
                        tmpRetAts = iAuth4Rec.d_qry_AuthCancel(tmpQryAuth4Rec);
                    } else if (tmpHeader.transType.equals("QueryRecAuthCancelInfo")) {
                        ReqQryRecAuthCancelInfo tmpQryRecAuthInfo = new ReqQryRecAuthCancelInfo(xmlReader, tmpHeader);
                        ICancelAuthorizeForRec iAuth4Rec = (ICancelAuthorizeForRec) tmpDirectBase;
                        tmpRetAts = iAuth4Rec.d_qry_AuthCancelInfo(tmpQryRecAuthInfo);
                    } else if (tmpHeader.transType.equals("5001") || tmpHeader.transType.toUpperCase().equals("REFUNDTICKET")) {
                        ReqQryRefund tmpQryRefund = new ReqQryRefund(xmlReader, tmpHeader);
                        IQryRefund iRefund = (IQryRefund) tmpDirectBase;
                        tmpRetAts = iRefund.d_qry_refund(tmpQryRefund);
                    } else if (tmpHeader.transType.equals("PayCurRate")) {
                        ReqExchangeRateQry tmpQryExchangeRate = new ReqExchangeRateQry(xmlReader, tmpHeader);
                        IExchangeRate iExchangeRate = (IExchangeRate) tmpDirectBase;
                        tmpRetAts = iExchangeRate.exchangeRate(tmpQryExchangeRate);
                    } else if (tmpHeader.transType.equals("LCIssueApp")) {//开证申请
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.issueApply(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("LCIssueAppEdit")) {
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.issueApplyEdit(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("DisConfirm")) {//不符点确认
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.disConfirm(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("OrderHonour")) {//来单承兑
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.orderHonour(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("OrderHonourEdit")) {
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.orderHonourEdit(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("OrderPay")) {//来单承付
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.orderPay(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("Dishonor")) {//拒付
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.dishonor(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("ChargeBackApply")) {//退单申请
                        ReqImportLCQry tmpImportLCQry = new ReqImportLCQry(xmlReader, tmpHeader);
                        IImportLC iImportLC = (IImportLC) tmpDirectBase;
                        tmpRetAts = iImportLC.chargeBackApply(tmpImportLCQry);
                    } else if (tmpHeader.transType.equals("B001")) {
                        ReqB001OperBillQry tmpB001 = new ReqB001OperBillQry(xmlReader, tmpHeader);
                        IElecBillQuery IQuery = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQuery.D_OperBill_Query_Req(tmpB001);
                    } else if (tmpHeader.transType.equals("B002")) {
                        ReqB002BillTransQry tmpB002 = new ReqB002BillTransQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B002_BillTrans_Query(tmpB002);
                    } else if (tmpHeader.transType.equals("B004")) {
                        ReqB004BillFrontQry tmpB004 = new ReqB004BillFrontQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B004_BillFront_Query(tmpB004);
                    } else if (tmpHeader.transType.equals("B005")) {
                        ReqB005BillBackQry tmpB005 = new ReqB005BillBackQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B005_BillBack_Query(tmpB005);
                    } else if (tmpHeader.transType.equals("B006")) {
                        ReqB006BillStateQry tmpB006 = new ReqB006BillStateQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B006_BillState_Qeury(tmpB006);
                    } else if (tmpHeader.transType.equals("B007")) {
                        ReqB007BillKzsrQry tmpB007 = new ReqB007BillKzsrQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B007_BillKzsr_Query(tmpB007);
                    } else if (tmpHeader.transType.equals("B008")) {
                        ReqB008HistoricalBillQry tmpB008 = new ReqB008HistoricalBillQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B008_HistoricalBillQuery(tmpB008);
                    } else if (tmpHeader.transType.equals("B009")) {
                        ReqB009DrawBillQry tmpB009 = new ReqB009DrawBillQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B009_DrawBillQuery(tmpB009);
                    } else if (tmpHeader.transType.equals("B010")) {
                        ReqB010ProtocolStateQry tmpB010 = new ReqB010ProtocolStateQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B010_ProtocolStateQuery(tmpB010);
                    } else if (tmpHeader.transType.equals("B011")) {
                        ReqB011TransFlagQry tmpB011 = new ReqB011TransFlagQry(xmlReader, tmpHeader);
                        IElecBillQuery IQeury = (IElecBillQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B011_TransFlagQuery(tmpB011);
                    } else if (tmpHeader.transType.equals("B012")) {
                        ReqB012BillTrialAmtQry tmpB012 = new ReqB012BillTrialAmtQry(xmlReader, tmpHeader);
                        IElecBillBankQuery IQeury = (IElecBillBankQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B012_TrialAmtQuery(tmpB012);
                    } else if (tmpHeader.transType.equals("B013")) {
                        ReqB013BillStateQry tmpB013 = new ReqB013BillStateQry(xmlReader, tmpHeader);
                        IElecBillBankQuery IQeury = (IElecBillBankQuery) tmpDirectBase;
                        tmpRetAts = IQeury.D_B013_BillStateQuery(tmpB013);
                    } else if (tmpHeader.transType.equals("B003")) {
                        ReqB003BillRespSubmit tmpB003 = new ReqB003BillRespSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B003_BillResp_Submit(tmpB003);
                    } else if (tmpHeader.transType.equals("B101")) {
                        ReqB101BillApplySubmit tmpB101 = new ReqB101BillApplySubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B101_BillResp_Submit(tmpB101);
                    } else if (tmpHeader.transType.equals("B102")) {
                        ReqB102BillAccpSubmit tmpB102 = new ReqB102BillAccpSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B102_BillResp_Submit(tmpB102);
                    } else if (tmpHeader.transType.equals("B103")) {
                        ReqB103BillRetSubmit tmpB103 = new ReqB103BillRetSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B103_BillResp_Submit(tmpB103);
                    } else if (tmpHeader.transType.equals("B104")) {
                        ReqB104BillReceSubmit tmpB104 = new ReqB104BillReceSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B104_BillResp_Submit(tmpB104);
                    } else if (tmpHeader.transType.equals("B105")) {
                        ReqB105BillEndoSubmit tmpB105 = new ReqB105BillEndoSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B105_BillResp_Submit(tmpB105);
                    } else if (tmpHeader.transType.equals("B106")) {
                        ReqB106BillDiscSubmit tmpB106 = new ReqB106BillDiscSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B106_BillResp_Submit(tmpB106);
                    } else if (tmpHeader.transType.equals("B107")) {
                        ReqB107BillPledSubmit tmpB107 = new ReqB107BillPledSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B107_BillResp_Submit(tmpB107);
                    } else if (tmpHeader.transType.equals("B108")) {
                        ReqB108BillPaySubmit tmpB108 = new ReqB108BillPaySubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B108_BillResp_Submit(tmpB108);
                    } else if (tmpHeader.transType.equals("B109")) {
                        ReqB109BillGuarSubmit tmpB109 = new ReqB109BillGuarSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B109_BillResp_Submit(tmpB109);
                    } else if (tmpHeader.transType.equals("B110")) {
                        ReqB110BillRecoSubmit tmpB110 = new ReqB110BillRecoSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B110_BillResp_Submit(tmpB110);
                    } else if (tmpHeader.transType.equals("B111")) {
                        ReqB111BillAgreeSubmit tmpB111 = new ReqB111BillAgreeSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B111_BillResp_Submit(tmpB111);
                    } else if (tmpHeader.transType.equals("B112")) {
                        ReqB112BillCancSubmit tmpB112 = new ReqB112BillCancSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B112_BillResp_Submit(tmpB112);
                    } else if (tmpHeader.transType.equals("B113")) {
                        ReqB113ProtocolSubmit tmpB113 = new ReqB113ProtocolSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B113_ProtocolResp_Submit(tmpB113);
                    } else if (tmpHeader.transType.equals("B114")) {
                        ReqB114BillAddSubmit tmpB114 = new ReqB114BillAddSubmit(xmlReader, tmpHeader);
                        IElecBillBankTrans ITrans = (IElecBillBankTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B114_BillAddSubmit(tmpB114);
                    } else if (tmpHeader.transType.equals("B115")) {
                        ReqB115BillDeleteSubmit tmpB115 = new ReqB115BillDeleteSubmit(xmlReader, tmpHeader);
                        IElecBillBankTrans ITrans = (IElecBillBankTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B115_BillDeleteSubmit(tmpB115);
                    } else if (tmpHeader.transType.equals("B116")) {
                        ReqB116BillApplySubmit tmpB116 = new ReqB116BillApplySubmit(xmlReader, tmpHeader);
                        IElecBillBankTrans ITrans = (IElecBillBankTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B116_BillApplySubmit(tmpB116);
                    } else if (tmpHeader.transType.equals("B119")) {
                        ReqB119BillRelePledSubmit tmpB119 = new ReqB119BillRelePledSubmit(xmlReader, tmpHeader);
                        IElecBillTrans ITrans = (IElecBillTrans) tmpDirectBase;
                        tmpRetAts = ITrans.D_B119_BillResp_Submit(tmpB119);
                    } else if (tmpHeader.transType.equals("BOB01")) {
                        ReqBatchQry tmpBOB01 = new ReqBatchQry(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchQry(tmpBOB01);
                    } else if (tmpHeader.transType.equals("BOB02")) {
                        ReqBatchInfoQry tmpBOB02 = new ReqBatchInfoQry(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchInfoQry(tmpBOB02);
                    } else if (tmpHeader.transType.equals("BOB03")) {
                        ReqBatchAddSubmit tmpBOB03 = new ReqBatchAddSubmit(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchAddSubmit(tmpBOB03);
                    } else if (tmpHeader.transType.equals("BOB04")) {
                        ReqBatchModSubmit tmpBOB04 = new ReqBatchModSubmit(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchModSubmit(tmpBOB04);
                    } else if (tmpHeader.transType.equals("BOB05")) {
                        ReqBatchDelSubmit tmpBOB05 = new ReqBatchDelSubmit(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchDelSubmit(tmpBOB05);
                    } else if (tmpHeader.transType.equals("BOB06")) {
                        ReqBatchSubmitApply tmpBOB06 = new ReqBatchSubmitApply(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchSubmitApply(tmpBOB06);
                    } else if (tmpHeader.transType.equals("BOB07")) {
                        ReqBatchSubmitCancel tmpBOB07 = new ReqBatchSubmitCancel(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.batchSubmitCancel(tmpBOB07);
                    } else if (tmpHeader.transType.equals("BOB08")) {
                        ReqBillAddSubmit tmpBOB08 = new ReqBillAddSubmit(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.billAddSubmit(tmpBOB08);
                    } else if (tmpHeader.transType.equals("BOB09")) {
                        ReqBillAddCancelSubmit tmpBOB09 = new ReqBillAddCancelSubmit(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.billAddCancelSubmit(tmpBOB09);
                    } else if (tmpHeader.transType.equals("Bat101")) {
                        ReqBatOpenBillSubmit tmpBOB101 = new ReqBatOpenBillSubmit(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.BatOpenBillSubmit(tmpBOB101);
                    } else if (tmpHeader.transType.equals("Bat101Qry")) {
                        ReqBatOpenBillSubmitQry tmpBOB101Qry = new ReqBatOpenBillSubmitQry(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.BatOpenBillSubmitQry(tmpBOB101Qry);
                    } else if (tmpHeader.transType.equals("BOB102")) {
                        ReqOrgQry reqOrgQry = new ReqOrgQry(xmlReader, tmpHeader);
                        IBatchOpenBill IBatch = (IBatchOpenBill) tmpDirectBase;
                        tmpRetAts = IBatch.orgQry(reqOrgQry);
                    } else if (tmpHeader.transType.equals("BP001")) {
                        ReqB301OperBillQry tmpB301 = new ReqB301OperBillQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP001_OperBill_Req(tmpB301);
                    } else if (tmpHeader.transType.equals("BP002")) {
                        ReqB305DealStateQry IQuery = new ReqB305DealStateQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP002_DealStateQry(IQuery);
                    } else if (tmpHeader.transType.equals("BP003")) {
                        ReqB306PoolAmountQry IQuery = new ReqB306PoolAmountQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP003_PoolAmountQry(IQuery);
                    } else if (tmpHeader.transType.equals("BP004")) {
                        ReqB308PoolAmountAdjustQry IQuery = new ReqB308PoolAmountAdjustQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP004_AdjustQry(IQuery);
                    } else if (tmpHeader.transType.equals("BP005")) {
                        ReqB312AssuranceDetail IQuery = new ReqB312AssuranceDetail(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP005_AssuracneDetail(IQuery);
                    } else if (tmpHeader.transType.equals("BP006")) {
                        ReqB315LoanDetail IQuery = new ReqB315LoanDetail(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP006_LoanDetail(IQuery);
                    } else if (tmpHeader.transType.equals("BP007")) {
                        ReqB329AssuranceTransmitQry IQuery = new ReqB329AssuranceTransmitQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP007_AssuranceTransmitQry(IQuery);
                    } else if (tmpHeader.transType.equals("BP008")) {
                        ReqBP008BillStateQry IQuery = new ReqBP008BillStateQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP008_BillState_Qeury(IQuery);
                    } else if (tmpHeader.transType.equals("BP009")) {
                        ReqB324InPoolRegister IQuery = new ReqB324InPoolRegister(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP009_InPoolRegister(IQuery);
                    } else if (tmpHeader.transType.equals("BP101")) {
                        ReqB302InPoolPledge IQuery = new ReqB302InPoolPledge(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP101_InPoolPledge_Req(IQuery);
                    } else if (tmpHeader.transType.equals("BP102")) {
                        ReqB304Impledge IQuery = new ReqB304Impledge(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP102_ImPledge(IQuery);
                    } else if (tmpHeader.transType.equals("BP103")) {
                        ReqB307PoolAmountAdjust IQuery = new ReqB307PoolAmountAdjust(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP103_PoolAmountAdjust(IQuery);
                    } else if (tmpHeader.transType.equals("BP104")) {
                        ReqB309BillApply IQuery = new ReqB309BillApply(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP104_BillApply(IQuery);
                    } else if (tmpHeader.transType.equals("BP105")) {
                        ReqB310ShortLoan IQuery = new ReqB310ShortLoan(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP105_ShortLoan(IQuery);
                    } else if (tmpHeader.transType.equals("BP106")) {
                        ReqB311LoanRepay IQuery = new ReqB311LoanRepay(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP106_LoanRepay(IQuery);
                    } else if (tmpHeader.transType.equals("BP107")) {
                        ReqB311AssuranceTransmit IQuery = new ReqB311AssuranceTransmit(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP107_AssuranceTransmit(IQuery);
                    } else if (tmpHeader.transType.equals("BP108")) {
                        ReqBP108BillCancSubmit IQuery = new ReqBP108BillCancSubmit(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP108_BillWithdrawalReq(IQuery);
                    } else if (tmpHeader.transType.equals("BP109")) {
                        ReqBP109BillRespSubmit IQuery = new ReqBP109BillRespSubmit(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP109_BillPublicrReply(IQuery);
                    } else if (tmpHeader.transType.equals("B317") || tmpHeader.transType.equals("BP901")) {
                        ReqB317OnlineFinancingApply IQuery = new ReqB317OnlineFinancingApply(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP901_OnlineFinancingApply(IQuery);
                    } else if (tmpHeader.transType.equals("B318") || tmpHeader.transType.equals("BP902")) {
                        ReqB318FinancingApplyQry IQuery = new ReqB318FinancingApplyQry(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP902_FinancingApplyQry(IQuery);
                    } else if (tmpHeader.transType.equals("B319") || tmpHeader.transType.equals("BP903")) {
                        ReqB319RebuildFile IQuery = new ReqB319RebuildFile(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP903_RebuildFile(IQuery);
                    } else if (tmpHeader.transType.equals("B320") || tmpHeader.transType.equals("BP904")) {
                        ReqB320ConfirmApplicationContract IQuery = new ReqB320ConfirmApplicationContract(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP904_ConfirmApplicationContract(IQuery);
                    } else if (tmpHeader.transType.equals("B321") || tmpHeader.transType.equals("BP905")) {
                        ReqB321QryFinancingApply IQuery = new ReqB321QryFinancingApply(xmlReader, tmpHeader);
                        IBillPool IPool = (IBillPool) tmpDirectBase;
                        tmpRetAts = IPool.BP905_QryFinancingApply(IQuery);
                    } else if (tmpHeader.transType.equals("CPTQ")) {
                        ReqCPTQCashPoolTreeQry IQuery = new ReqCPTQCashPoolTreeQry(xmlReader, tmpHeader);
                        ICashPool IPool = (ICashPool) tmpDirectBase;
                        tmpRetAts = IPool.CPTQ_CashPoolTreeQry(IQuery);
                    } else if (tmpHeader.transType.equals("CPAQ")) {
                        ReqCPAQCashPoolAccQry IQuery = new ReqCPAQCashPoolAccQry(xmlReader, tmpHeader);
                        ICashPool IPool = (ICashPool) tmpDirectBase;
                        tmpRetAts = IPool.CPAQ_CashPoolAccQry(IQuery);
                    } else if (tmpHeader.transType.equals("CPASQ")) {
                        ReqCPASQCashPoolAccSignInfoQry IQuery = new ReqCPASQCashPoolAccSignInfoQry(xmlReader, tmpHeader);
                        ICashPool IPool = (ICashPool) tmpDirectBase;
                        tmpRetAts = IPool.CPASQ_CashPoolAccSignInfoQry(IQuery);
                    } else if ("QrySmsRecUserInfo".equals(tmpHeader.transType)) {
                        ReqQryUserInfo tmpQryReq = new ReqQryUserInfo(xmlReader, tmpHeader);
                        IQryUserInfo iQryUserInfo = (IQryUserInfo) tmpDirectBase;
                        tmpRetAts = iQryUserInfo.qrySmsRecUserInfo(tmpQryReq);
                    } else if ("AQ01".equals(tmpHeader.transType)) {
                        ReqAQ01BalQry tmpReqAQ01 = new ReqAQ01BalQry(xmlReader, tmpHeader);
                        IQuoteCheck iQuoteCheck = (IQuoteCheck) tmpDirectBase;
                        tmpRetAts = iQuoteCheck.d_AQ01_BalQry(tmpReqAQ01);
                    } else if ("QryQuotaInfo".equals(tmpHeader.transType)) {
                        ReqQryQuotaInfo qryQuotaInfo = new ReqQryQuotaInfo(xmlReader, tmpHeader);
                        IQuotaInfo iQuotaInfo = (IQuotaInfo) tmpDirectBase;
                        tmpRetAts = iQuotaInfo.queryQuotaInfo(qryQuotaInfo);
                    } else if ("QryFinanceRecInfo".equals(tmpHeader.transType)) {
                        ReqQryFinanceRecInfo qryFinanceRecInfo = new ReqQryFinanceRecInfo(xmlReader, tmpHeader);
                        IFinanceRecInfo iFinanceRecInfo = (IFinanceRecInfo) tmpDirectBase;
                        tmpRetAts = iFinanceRecInfo.qryFinanceRecInfo(qryFinanceRecInfo);
                    } else if ("QryInCustodyInfo".equals(tmpHeader.transType)) {
                        ReqQryInCustodyInfo qryInCustodyInfo = new ReqQryInCustodyInfo(xmlReader, tmpHeader);
                        IInCustodyInfo iInCustodyInfo = (IInCustodyInfo) tmpDirectBase;
                        tmpRetAts = iInCustodyInfo.qryInCustodyInfo(qryInCustodyInfo);
                    } else if ("QryUndueBillInfo".equals(tmpHeader.transType)) {
                        ReqQryUndueBillInfo qryUndueBillInfo = new ReqQryUndueBillInfo(xmlReader, tmpHeader);
                        IUndueBillInfo iUndueBillInfo = (IUndueBillInfo) tmpDirectBase;
                        tmpRetAts = iUndueBillInfo.qryUndueBillInfo(qryUndueBillInfo);
                    } else if ("OrderMsg".equals(tmpHeader.transType)) {
                        ReqOrderMsgQry orderMsgQry = new ReqOrderMsgQry(xmlReader, tmpHeader);
                        IOrderMsg iOrderMsg = (IOrderMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iOrderMsg.pushOrderMsg(orderMsgQry);
                    } else if ("MailedMsg".equals(tmpHeader.transType)) {
                        ReqMailedMsgQry mailedMsgQry = new ReqMailedMsgQry(xmlReader, tmpHeader);
                        IMailedMsg iMailedMsg = (IMailedMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iMailedMsg.getMailedMsg(mailedMsgQry);
                    } else if ("RetailStockMsg".equals(tmpHeader.transType)) {
                        ReqRetailStockMsgQry retailStockMsgQry = new ReqRetailStockMsgQry(xmlReader, tmpHeader);
                        IRetailStockMsg iRetailStockMsg = (IRetailStockMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iRetailStockMsg.getRetailStockMsg(retailStockMsgQry);
                    } else if ("RetailMsg".equals(tmpHeader.transType)) {
                        ReqRetailMsgQry retailMsgQry = new ReqRetailMsgQry(xmlReader, tmpHeader);
                        IRetailMsg iRetailMsg = (IRetailMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iRetailMsg.getRetailMsg(retailMsgQry);
                    } else if ("PrivateSaleMsg".equals(tmpHeader.transType)) {
                        ReqPrivateSaleMsgQry msgQry = new ReqPrivateSaleMsgQry(xmlReader, tmpHeader);
                        IPrivateSaleMsg iPrivateSaleMsg = (IPrivateSaleMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iPrivateSaleMsg.getPrivateSaleMsg(msgQry);
                    } else if ("PrivateMoveMsg".equals(tmpHeader.transType)) {
                        ReqPrivateMoveMsgQry msgQry = new ReqPrivateMoveMsgQry(xmlReader, tmpHeader);
                        IPrivateMoveMsg iPrivateMoveMsg = (IPrivateMoveMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iPrivateMoveMsg.getPrivateMoveMsg(msgQry);
                    } else if ("RelationDN".equals(tmpHeader.transType)) {
                        ReqRelationDN reqRelationDN = new ReqRelationDN(xmlReader, tmpHeader);
                        IRelationDN iRelationDN = (IRelationDN) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iRelationDN.d_RelationDN(reqRelationDN);
                    } else if ("InvoiceMsg".equals(tmpHeader.transType)) {
                        ReqInvoiceMsgQry msgQry = new ReqInvoiceMsgQry(xmlReader, tmpHeader);
                        IInvoiceMsg iInvoiceMsg = (IInvoiceMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iInvoiceMsg.getInvoiceMsg(msgQry);
                    } else if ("CertificateMailedMsg".equals(tmpHeader.transType)) {
                        ReqCertificateMailedMsgQry msgQry = new ReqCertificateMailedMsgQry(xmlReader, tmpHeader);
                        ICertificateMailedMsg iCertificateMailedMsg = (ICertificateMailedMsg) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iCertificateMailedMsg.getCertificateMailedMsg(msgQry);
                    } else if ("AuditAccount".equals(tmpHeader.transType)) {
                        ReqAuditAccount msgQry = new ReqAuditAccount(xmlReader, tmpHeader);
                        IAuditAccount iAuditAccount = (IAuditAccount) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iAuditAccount.retAtsAuditAccountQry(msgQry);
                    } else if ("TransactionReplenish".equals(tmpHeader.transType)) {
                        ReqTransactionReplenish transactionReplenishQry = new ReqTransactionReplenish(xmlReader, tmpHeader);
                        ITransactionReplenish iTransactionReplenish = (ITransactionReplenish) tmpDirectBase;
                        tmpRetAts = (RetAtsBase) iTransactionReplenish.qryTransactionReplenish(transactionReplenishQry);
                    } else if ("8710".equals(tmpHeader.transType)) {
                        ReqPushTransInfo reqPushTransInfo = new ReqPushTransInfo(xmlReader, tmpHeader);
                        IPushInfoToBank iPushInfoToBank = (IPushInfoToBank) tmpDirectBase;
                        tmpRetAts = iPushInfoToBank.pushTransInfoToBank(reqPushTransInfo);
                    } else {
                        ReqOtherElse tmpReqElse = new ReqOtherElse(xmlReader, tmpHeader);
                        IOtherElse iOtherElse = (IOtherElse) tmpDirectBase;
                        tmpRetAts = iOtherElse.d_else(tmpReqElse);
                    }
                    if (tmpRetAts != null) {
                        tmpRespBody = tmpRetAts.getRetAtsString();
                    } else {
                        tmpRespBody = setErrorResp("1." + tmpHeader.bankCode + "未实现接口" + tmpHeader.transType, tmpHeader.transType);
                    }
                } else {
                    tmpRespBody = setErrorResp("2." + tmpHeader.bankCode + "未实现接口" + tmpHeader.transType, tmpHeader.transType);
                }
            } catch (ClassNotFoundException e) {
                FGBiz.limitMsg.exception("Class.forName", e, className);
                tmpRespBody = setErrorResp("3." + tmpHeader.bankCode + "未实现接口" + tmpHeader.transType, tmpHeader.transType);
            } catch (Throwable e) {
                FGBiz.limitMsg.exception(tmpHeader.bankCode + "." + tmpHeader.transType, e);
                tmpRespBody = setErrorResp(LogHelper.getStackTrace(e), tmpHeader.transType);
            }
            if (tmpRespBody.contains("E9999") || tmpRespBody.contains("Connection refused") || tmpRespBody.contains("Read timed out")) {
                tmpBankFront.frontStatus.status = EnBfStatus.exception;
                tmpBankFront.frontStatus.statusTime = new Date();
                if (tmpRespBody.contains("Read timed out")) {
                    tmpBankFront.frontStatus.statusInfo = "通讯超时";
                } else {
                    tmpBankFront.frontStatus.statusInfo = "通讯失败";
                }
            } else if (tmpRespBody.contains("<RespCode>0</RespCode>") && !tmpRespBody.contains("E1301") && !tmpRespBody.contains("E9981")) {
                tmpBankFront.frontStatus.status = EnBfStatus.normal;
                tmpBankFront.frontStatus.statusTime = new Date();
                tmpBankFront.frontStatus.statusInfo = "正常";
                if (tmpHeader.transType.equals("7506")) {
                    if (StringHelper.isNullOrEmpty(tmpBankFront.frontStatus.cmdPckForCheck)) {
                        tmpBankFront.frontStatus.cmdPckForCheck = oriAtsReqStr;
                    } else if (tmpBankFront.frontStatus.cmdPckForCheck.length() > oriAtsReqStr.length()) {
                        tmpBankFront.frontStatus.cmdPckForCheck = oriAtsReqStr;
                    }
                }
            }
            if ("2".equals(tmpBankFront.checkLevel) && (!tmpRespBody.contains("<RespCode>0</RespCode>")) && tmpRespBody.contains("<RespInfo>") && tmpRespBody.contains("</RespInfo>")) {
                tmpBankFront.frontStatus.status = EnBfStatus.exception;
                tmpBankFront.frontStatus.statusTime = new Date();
                String beginIndexFlag = "<RespInfo>";
                String endIndexFlag = "</RespInfo>";
                tmpBankFront.frontStatus.statusInfo = tmpRespBody.substring(tmpRespBody.indexOf(beginIndexFlag) + beginIndexFlag.length(), tmpRespBody.indexOf(endIndexFlag));
            }

        } else {
            tmpRespBody = setErrorResp("没有符合要求的前置机", tmpHeader.transType);
        }
        return tmpRespBody;
    }

    private RetAtsB001OperBillQryDetail getBillDetail(String[] detailArr) {
        RetAtsB001OperBillQryDetail detail = new RetAtsB001OperBillQryDetail();
        //持票人|撤销人|票据号|金额|票据类型|出票日|到期日|转让|
        //出票人名称|出票人账号|出票人开户行|
        //承兑人名称|承兑人账号|承兑人开户行|
        //收款人名称|收款人账号|收款人开户行|申请前的票据状态|票据状态
        detail.billNo = detailArr[2];
        detail.billAmt = detailArr[3];
        detail.billType = detailArr[4];
        detail.issDate = detailArr[5];
        detail.dueDate = detailArr[6];
        detail.transFlag = detailArr[7];
        detail.drawName = detailArr[8];
        detail.drawAct = detailArr[9];
        detail.drawBnkCode = detailArr[10];
        detail.accpName = detailArr[11];
        detail.accpAct = detailArr[12];
        detail.accpBnkCode = detailArr[13];
        detail.payeeName = detailArr[14];
        detail.payeeAct = detailArr[15];
        detail.payeeBnkCode = detailArr[16];
        detail.billStatus = "220706".equals(detailArr[18]) ? "220707" : detailArr[18];
        return detail;
    }

    public String setErrorResp(String p_err, String p_transType) {
        if (p_transType.equals("1908") || p_transType.equals("1944") || p_transType.equals("9108") || p_transType.equals("9144")) {
            return "<ATSYH><TransResp><TransParam><DetailRecord><RespCode>-1</RespCode><RespInfo>" + XmlHelper.encode(p_err) + "</RespInfo></DetailRecord></TransParam></TransResp></ATSYH>";
        } else if (p_transType.equals("1908BAT") || p_transType.equals("1944BAT")) {
            return "<ATSYH><TransResp><TransParam><BatRespCode>-1</BatRespCode><BatRespInfo>" + XmlHelper.encode(p_err) + "</BatRespInfo></TransParam></TransResp></ATSYH>";
        } else {
            return "<ATSYH><TransResp><TransParam><RespCode>-1</RespCode><RespInfo>" + XmlHelper.encode(p_err) + "</RespInfo></TransParam></TransResp></ATSYH>";
        }
    }

    public String getBillNo() {
        String billNo = "";
        for (int i = 0; i < 5; i++) {
            Random random = new Random();
            int ends = random.nextInt(999999);
            billNo += String.format("%06d", ends);
        }
        return billNo;
    }

    /**
     * @param billDir     票据文件夹
     * @param tmpRespBody 模板xml
     * @param billNo      票据号
     * @param actnum      可申请或者可签收账号
     * @param cancleNum   可撤销账号
     * @param billstate   现在的票据状态
     * @param flag        1-申请类 2-同意签收 3-拒绝签收 4-撤回 5-同意清除撤回 6-同意清偿同意 7-同意清偿拒绝
     * @param operater    操作类型
     * @throws Exception
     */
    public String updateBillState(String billDir, String tmpRespBody, String billNo,
                                  String actnum, String cancleNum, String billstate, String flag, String operater) throws Exception {
        String[] filenames = new File(billDir).list();
        String billName = "";
        for (String filename : filenames) {
            if (filename.contains(billNo)) {
                tmpRespBody = tmpRespBody.replace("{$BillNo}", filename.split("_")[1]);
                billName = filename;
                break;
            }
        }
        //判断是否可以发起对应的业务操作
        String fileDatail = FileHelper.readToString(new File(billDir + File.separator + billName), "GBK");
        String[] detailArr = fileDatail.split("\\|");
        boolean canSubmit = canSubmit(detailArr[18], operater);
        if (!canSubmit) {
            return tmpRespBody.replace("AAAAAAA", "ED03309");

        }
        StringBuilder stringBuilder = new StringBuilder();
        if ("1".equals(flag)) {
            detailArr[0] = actnum;
            detailArr[1] = cancleNum;
            detailArr[17] = detailArr[18];
            detailArr[18] = billstate;
        } else if ("2".equals(flag)) {
            detailArr[0] = actnum;
            detailArr[1] = "";
            detailArr[17] = "";
            detailArr[18] = billstate;
        } else if ("3".equals(flag)) {
            if (!"2011".equals(operater) && !"2006".equals(operater)) {
                detailArr[0] = detailArr[1];
                detailArr[1] = "";
                detailArr[18] = detailArr[17];
                detailArr[17] = "";
            }
        } else if ("4".equals(flag)) {
            detailArr[0] = detailArr[1];
            detailArr[1] = "";
            detailArr[18] = detailArr[17];
            detailArr[17] = "";
        } else if ("5".equals(flag)) {
            detailArr[1] = detailArr[0];//撤销人变追索人
            detailArr[0] = actnum;//申请人变被追索人
            detailArr[18] = billstate;
        } else if ("6".equals(flag)) {
            detailArr[0] = detailArr[1];//撤销人变签收人
            detailArr[1] = actnum;//撤销人是被追索人
            detailArr[18] = billstate;
        } else if ("7".equals(flag)) {
            detailArr[0] = detailArr[1];
            detailArr[1] = "";
            detailArr[17] = "";
            detailArr[18] = billstate;
        }
        stringBuilder.append(detailArr[0]);
        for (int i = 1; i < detailArr.length; i++) {
            stringBuilder.append("|" + detailArr[i]);
        }
        FileHelper.writeFile(billDir + File.separator + billName, stringBuilder.toString(), "GBK");
        return tmpRespBody;
    }

    /**
     * 是否可以发起对应的票据操作
     *
     * @param billState 此时的票据状态
     * @param operater  票据操作
     * @return
     */
    public boolean canSubmit(String billState, String operater) {
        if ("1002".equals(operater)) {//提示承兑
            if (!"010004".equals(billState)) {
                return false;
            }
        } else if ("1003".equals(operater)) {//提示收票
            if (!"020006".equals(billState)) {
                return false;
            }
        } else if ("1004".equals(operater)) {//背书申请
            if (!"030006".equals(billState) && !"100006".equals(billState) &&
                    !"190006".equals(billState) && !"120006".equals(billState)) {
                return false;
            }
        } else if ("1005".equals(operater)) {//质押申请
            if (!"030006".equals(billState) && !"100006".equals(billState) &&
                    !"190006".equals(billState) && !"120006".equals(billState)) {
                return false;
            }
        } else if ("1010".equals(operater)) {//贴现申请
            if (!"030006".equals(billState) && !"100006".equals(billState) &&
                    !"190006".equals(billState) && !"120006".equals(billState)) {
                return false;
            }
        } else if ("1012".equals(operater)) {//提示付款申请
            if (!"030006".equals(billState) && !"100006".equals(billState) &&
                    !"190006".equals(billState) && !"120006".equals(billState) &&
                    !"220706".equals(billState) && !"200512".equals(billState)) {
                return false;
            }
        } else if ("1013".equals(operater)) {//追索申请
            if (!"030006".equals(billState) && !"100006".equals(billState) &&
                    !"190006".equals(billState) && !"120006".equals(billState) &&
                    !"220706".equals(billState) && !"200512".equals(billState)) {
                return false;
            }
        } else if ("1014".equals(operater)) {//同意清偿申请
            if (!"220707".equals(billState)) {
                return false;
            }
        } else if ("3001".equals(operater)) {//
            if (!"010004".equals(billState) && !"020006".equals(billState)) {
                return false;
            }
        } else if ("3002".equals(operater)) {
            if (!"020001".equals(billState)) {
                return false;
            }
        } else if ("3003".equals(operater)) {
            if (!"030001".equals(billState)) {
                return false;
            }
        } else if ("3004".equals(operater)) {
            if (!"100001".equals(billState)) {
                return false;
            }
        } else if ("3005".equals(operater)) {
            if (!"180001".equals(billState)) {
                return false;
            }
        } else if ("3010".equals(operater)) {
            if (!"110101".equals(billState) && !"110201".equals(billState)) {
                return false;
            }
        } else if ("3012".equals(operater)) {
            if (!"200001".equals(billState)) {
                return false;
            }
        } else if ("3013".equals(operater)) {
            if (!"220707".equals(billState)) {
                return false;
            }
        } else if ("3014".equals(operater)) {
            if (!"230701".equals(billState)) {
                return false;
            }
        } else if ("2003".equals(operater)) {
            if (!"030001".equals(billState)) {
                return false;
            }
        } else if ("2004".equals(operater)) {
            if (!"100001".equals(billState)) {
                return false;
            }
        } else if ("2006".equals(operater)) {
            if (!"190001".equals(billState)) {
                return false;
            }
        } else if ("2011".equals(operater)) {
            if (!"120001".equals(billState)) {
                return false;
            }
        } else if ("2014".equals(operater)) {
            if (!"230701".equals(billState)) {
                return false;
            }
        }
        return true;
    }

    private void writeApplyHeader(XmlTextWriter applyXml, String actNum, RetAtsB009DrawBillQryProtocolDetail protocolDetail, ReqRespHeader reqHeader) {
        applyXml.writeStartDocument();
        applyXml.writeStartElement("ATSYH");
        applyXml.writeStartElement("TransReq");

        applyXml.writeElementString("BankCode", reqHeader.bankCode);
        applyXml.writeElementString("Entity", reqHeader.corporation);
        applyXml.writeElementString("SystemCode", "");
        applyXml.writeElementString("TransType", "B113");
        applyXml.writeElementString("TransSeqID", "");
        applyXml.writeElementString("TransTime", Format.DateTimeFormat.format(new Date()));
        applyXml.writeStartElement("TransParam");
    }

    private void writeApplyDetail(XmlTextWriter applyXml, RetAtsB009DrawBillQryTransDetail detail) throws Exception {
        applyXml.writeStartElement("DetailRecord");
        applyXml.writeElementString("BillNum", detail.billNum);
        if ("EM001".equals(detail.billType)) {
            applyXml.writeElementString("BillType", "1");
        } else if ("EM002".equals(detail.billType)) {
            applyXml.writeElementString("BillType", "2");
        } else {
            applyXml.writeElementString("BillType", "");
        }
        applyXml.writeElementString("BillAmt", detail.billAmt);
        applyXml.writeElementString("BillCur", "");
        applyXml.writeElementString("IssDate",
                Format.DateTime21Format.format(Format.Date10Format.parse(detail.issDate)));
        applyXml.writeElementString("DueDate",
                Format.DateTime21Format.format(Format.Date10Format.parse(detail.dueDate)));
        applyXml.writeElementString("ContractNo", detail.contractNo);
        applyXml.writeElementString("InvoiceNo", detail.invoiceNo);
        applyXml.writeElementString("TransFlag", "1");
        applyXml.writeElementString("MustPay", "");
        applyXml.writeElementString("Memo", "");
        applyXml.writeElementString("DrawName", detail.drawName);
        applyXml.writeElementString("DrawAct", detail.drawAct);
        applyXml.writeElementString("DrawActArea", "");
        applyXml.writeElementString("DrawCode", "");
        applyXml.writeElementString("DrawBnkName", detail.drawBnkName);
        applyXml.writeElementString("DrawBnkCode", detail.drawBnkCode);
        applyXml.writeElementString("AccpName", detail.accpName);
        applyXml.writeElementString("AccpAct", detail.accpAct);
        applyXml.writeElementString("AccpCode", "");
        applyXml.writeElementString("AccpBnkName", detail.accpBnkName);
        applyXml.writeElementString("AccpBnkCode", detail.accpBnkCode);
        applyXml.writeElementString("AccpSameBnk", "");
        applyXml.writeElementString("PayeeName", detail.payeeName);
        applyXml.writeElementString("PayeeAct", detail.payeeAct);
        applyXml.writeElementString("PayeeBnkName", detail.payeeBnkName);
        applyXml.writeElementString("PayeeBnkCode", detail.payeeBnkCode);
        applyXml.writeElementString("PayeeSameBnk", "");
        applyXml.writeElementString("PostScript", "");
        applyXml.writeElementString("ReqReserve3", "");
        applyXml.writeElementString("ReqReserve4", "");
        applyXml.writeEndElement();
    }

    private void writeApplyProtocol(XmlTextWriter applyXml, RetAtsB009DrawBillQryProtocolDetail protocolDetail) {
        applyXml.writeElementString("ProtocolNo", protocolDetail.protocolNo);
        applyXml.writeElementString("TotalAmount", protocolDetail.protocolAmount);
        applyXml.writeElementString("TotalNum", protocolDetail.list.size() + "");
        applyXml.writeElementString("ReqBatchNo", "1111");
        applyXml.writeElementString("CreditLv", "");
        applyXml.writeElementString("GradeAgent", "");
        applyXml.writeElementString("GradeDueDate", "");
        applyXml.writeElementString("ReqReserve1", "");
        applyXml.writeElementString("ReqReserve2", "");
    }
}